コード例 #1
0
ファイル: embedhttp.cpp プロジェクト: Refection/freestyledash
int ehttp::out_commit_memory(void)
{
    // Setup our local variables
    //if(!MmIsAddressValid((ULONGLONG)m_Buffer))
    //	return 0;

    CHAR* currentPos = (CHAR*)m_Buffer;
    DWORD sizeLeft = m_Length;

    // Loop while we still have data to send
    int status = 0;
    while(sizeLeft > 0) {

        // Send our data and break if we fail to send
        DWORD sendLen = min(1024 * 128, sizeLeft);
        if((status = pSend((void*)localFD, currentPos, sendLen, ptheCookie)) < 0)
            break;

        // Decrement our size left
        currentPos += status;
        sizeLeft -= status;
    }

    if(m_Buffer) {
        free(m_Buffer);
        m_Length = 0;
    }


    // Return our result
    return status;
}
コード例 #2
0
ファイル: ProtoSSL.cpp プロジェクト: OrfeasZ/EA-MITM
	int __cdecl ProtoSSL::mSend(void *state, const char *buffer, unsigned int length) {
		if (length > 0) {
			connections_mutex_.lock();
			if (connections_.find(state) != connections_.end()) {
				ProtoSSL::Connection &connection = connections_[state];
				dump_.Write(SOCK_STREAM, IPPROTO_TCP, connection.LocalEndpoint.Address, connection.LocalEndpoint.Port,
					connection.RemoteEndpoint.Address, connection.RemoteEndpoint.Port, const_cast<char *>(buffer), length);

				base::EA_MITM::Log->Write(indigo::kLogType_Info, "EA::ProtoSSL", "Send: [%i] Sent %i bytes to %s:%i", 
					connection.ID, length, connection.RemoteEndpoint.AddressString.c_str(), connection.RemoteEndpoint.Port);
			}
			connections_mutex_.unlock();			
		}

		return pSend(state, buffer, length);
	}
コード例 #3
0
ファイル: embedhttp.cpp プロジェクト: Refection/freestyledash
int ehttp::out_commit(int header)
{
    int w;
    int err=0;

    if( filetype == EHTTP_BINARY_FILE )
        return out_commit_binary();

    if( filetype == EHTTP_MEMORY_FILE )
        return out_commit_memory();

    if( header == EHTTP_HDR_OK )
    {
        string headr("HTTP/1.0 200 OK\r\n");
        map <string, string>::const_iterator iter;
        iter=response_header.begin();
        //Send out all the headers you want
        while( iter != response_header.end() )
        {
            headr+=iter->first+string(": ")+iter->second+string("\r\n");
            ++iter;
        }
        outbuffer=headr+string("\r\n")+outbuffer;
    }
    else if( header == EHTTP_LENGTH_REQUIRED )
    {
        outbuffer=string("HTTP/1.0 411 Length Required\r\n\r\n");
    }


    int remain=outbuffer.length();
    int total=remain;
    while( remain )
    {
        w=pSend((void*)localFD,outbuffer.c_str()+(total-remain),remain,ptheCookie);
        if( w<0 )
        {
            err=w;
            remain=0;
        }
        else
            remain-=w;
    }
    return err;
}
コード例 #4
0
int WINAPI MySend(SOCKET s, const char* buf, int len, int flags)
{
	int iResult;
	MsgBox("HookDll : Entered MySend");
	//fopen_s(&pSendLogFile, "C:\\Users\\Itay\\Documents\\SendLog.txt", "a+");
	//fprintf(pSendLogFile, "%s\n", buf);
	//fclose(pSendLogFile);

	iResult = pSend(ConnectSocket, "Message from dllmain", len, flags);
	if (iResult == SOCKET_ERROR) {
		MsgBox("send failed with error: \n");
		pClosesocket(ConnectSocket);
		pWSACleanup();
		return 1;
	}
	else MsgBox("send succeded");
	return iResult;
}
コード例 #5
0
void client2() {
        int s=50;
	int c = 7;
        printf("Starting second client=client2 at port %d\n",c);
        message[0]=7;
	for(;;){

        int count=1;
        int mCount=1;
       
        while(count<=10){
        message[count]=rand()%7;
        count++;
        }  
        pSend(message,c,s,2);
        printf("\n");
	send(message,s,c);
        receive(message,c);
        pReceive(message,c,s,2);
        printf("\n");
        sleep(1);
	}
}
コード例 #6
0
ファイル: embedhttp.cpp プロジェクト: Refection/freestyledash
int ehttp::out_commit_binary(void)
{
    int err=0;
    FILE *f=fopen(outfilename.c_str(),"rb");
    char buffer[1024*128];
    if(f)
    {
        while( !feof(f) )
        {
            int r=fread(buffer,1,1024*128,f);
            if( r>0 )
            {
                int remain=r;
                int total=remain;
                while( remain )
                {
                    int w=pSend((void*)localFD,buffer+(total-remain),remain,ptheCookie);
                    if( w<0 )
                    {
                        err=w;
                        remain=0;

                        fseek(f,0,SEEK_END);

                    }
                    else
                    {
                        remain-=w;
                    }
                }
            }
        }
        fclose(f);
    }
    return err;
}