Jump to content

Http redirection in C/C++

- - - - -

  • Please log in to reply
8 replies to this topic

#1
mnirahd

mnirahd

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 330 posts
Hi,

What can be a best way of doing Http redirection: Whether should I go for Layered Service Provider or use Libpcap for this?

Thanks
-Munir

#2
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,254 posts
  • Location:C:\Countries\US
Sorry for the questions, but what are Layered Service Provider and Libpcap?

#3
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
@RR, LSP and libpcap are libraries that insert itself in to the TCP/IP stack for example to capture data or manipulate traffic (wireshark or traffic spectrum analysers often use libpcap for example)

@Munir
From what I can see LSP SPI is fairly undocumented, this is especially true because it is a more unused part of the Winsock API, although I think it is what you need to use as libpcap was made with analysing in mind rather than modifying inbound or outbound traffic. (if I get what you are wanting to do)
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#4
julmuri

julmuri

    Programmer

  • Members
  • PipPipPipPip
  • 139 posts
You can do this with pcap, and you should.
Developing lsp can be tedious, as you will most likely corrupt your tcp/ip stack more than once.
std::string s("oberq zhpu?");std::for_each(s.begin(),s.end(),[&](char&c){c=~c;c=~c-0x01/(~(c|0x20)/0x0D*0x02-0x0B)*0x0D;});std::cout<<s;

#5
mnirahd

mnirahd

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 330 posts
Hi,

I did it using LSP: I thought its more easy than using pCap: as I simply added my code to WSPSend/WSRecv function to stop or redirect http request.

Thanks
-Munir

#6
jburkeen

jburkeen

    Newbie

  • Members
  • Pip
  • 1 posts
Hi Munir,

I have attempted to add http redirection as well using the LSP WSPSend/WSPRecv functions. The redirection works fine in IE/Firefox, but fails in Chrome. Any thoughts? Does your redirection work in all browsers? Would you be willing to share your code?

Thanks,
Jared

#7
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,254 posts
  • Location:C:\Countries\US
Do you guys actually send HTTP code (as in socket programming), or are those pCap/LSP high-level function libraries?

#8
mnirahd

mnirahd

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 330 posts
Hi,

Chrome uses overlapped you have to wait within WSPRecv for the overlapped io to get completed.

BTW, I'm having performance issue: can you share with me your code: I ll add code for Chrome so it helps both of us :-)

-Munir

#9
EyeballKid

EyeballKid

    Newbie

  • Members
  • Pip
  • 7 posts

mnirahd said:

Hi,

What can be a best way of doing Http redirection: Whether should I go for Layered Service Provider or use Libpcap for this?

I was really confused there for a minute... "HTTP redirection" usually means handling 3xx return codes... but you're talking about LSP and pcap, so I assume you're really trying to listen in on http traffic, right?
Looking for a job that doesn't suck? Try not getting hired to make posts with a spam-sig!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users