Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting raw HTTP request from CFHTTPMessageRef

I am working with a wrapper class for CFHTTPMessage, which contains a CFHTTPMessageRef object to which is added the method (GET), the URL of the web application server, and a few custom headers containing the date and an authentication nonce.

I'm having some problems getting the method and URL to return certain data. I think I've worked out the authentication nonce.

I'd like to troubleshoot this by looking at the raw request going to the web application, and making sure everything is formatted properly.

My question is: If I have a CFHTTPMessageRef object (e.g. messageRef), is there a way to log the raw HTTP request that comes out of this message?

I've tried the following but I get a EXC_BAD_ACCESS signal when I try to access its bytes:

CFDataRef messageData = CFHTTPMessageCopyBody(messageRef);

Thanks for any advice.

As an alternative, is it possible to use a packet sniffer on a switched network? I can run ettercap on a laptop device, but don't know how to sniff what my iPhone is doing on the local wireless network.

like image 832
Alex Reynolds Avatar asked Jan 24 '23 23:01

Alex Reynolds


1 Answers

The following worked well:

NSData *d = (NSData *)CFHTTPMessageCopySerializedMessage(messageRef);
NSLog(@"%@",[[[NSString alloc] initWithBytes:[d bytes] length:[d length] encoding:NSUTF8StringEncoding] autorelease]);

Hope this is helpful to others.

like image 52
Alex Reynolds Avatar answered Jan 29 '23 09:01

Alex Reynolds