1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
void BuildPayload(string* PtrPayloadBuffer, string Stuff)
{
string Part1="<Payload>";
string Part2="</Payload>";
(*PtrPayloadBuffer).clear();
(*PtrPayloadBuffer).append(Part1);
(*PtrPayloadBuffer).append(Stuff);
(*PtrPayloadBuffer).append(Part2);
}
void BuildHeader(string* PtrHeaderBuffer, string* PtrPayloadBuffer, sockaddr_in RemoteServer)
{
string Part1="POST /login.jsp HTTP/1.1\nHost: ";
string Part2="\nContent-Length: ";
string Part3="\nContent-Type: text/html; charset=ISO-8859-4\r\n\r\n";
char * MsgSize=(char*) malloc (sizeof(char) * 5); memset(MsgSize,0,5);
int DontCare;
DontCare=sprintf(MsgSize, "%d", PtrPayloadBuffer->size());
(*PtrHeaderBuffer).clear();
(*PtrHeaderBuffer).append(Part1);
(*PtrHeaderBuffer).append("10.1.1.100"); // don't know how to encode IP Addr as string
(*PtrHeaderBuffer).append(Part2);
(*PtrHeaderBuffer).append(MsgSize);
(*PtrHeaderBuffer).append(Part3);
}
int main(int argc, char * argv[])
{
// Build socket to remote server 10.1.1.100
BuildPayload(PtrPayloadBuffer, AppName, L4Proto, L4Port);
BuildHeader(PtrHeaderBuffer, PtrPayloadBuffer, RemoteServer);
HeaderBuffer.append(PayloadBuffer);
// Write string HeaderBuffer to socket, then close
return 1;
}
|