Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
GeneralRe: Casting an anonymous type Pin
Guffa4-May-08 21:38
Guffa4-May-08 21:38 
GeneralRe: Casting an anonymous type Pin
Roger Alsing5-May-08 6:21
Roger Alsing5-May-08 6:21 
QuestionIssue with Setup and Deployment Project Pin
paas4-May-08 6:05
paas4-May-08 6:05 
QuestionManipulate sender ip on TCPCLIENT (port forwarding application with internal packet checks) Pin
Jan Weltmeyer4-May-08 5:44
Jan Weltmeyer4-May-08 5:44 
AnswerRe: Manipulate sender ip on TCPCLIENT (port forwarding application with internal packet checks) Pin
Dave Kreskowiak4-May-08 15:47
mveDave Kreskowiak4-May-08 15:47 
GeneralRe: Manipulate sender ip on TCPCLIENT (port forwarding application with internal packet checks) Pin
Jan Weltmeyer5-May-08 2:45
Jan Weltmeyer5-May-08 2:45 
GeneralRe: Manipulate sender ip on TCPCLIENT (port forwarding application with internal packet checks) Pin
Dave Kreskowiak5-May-08 18:44
mveDave Kreskowiak5-May-08 18:44 
AnswerRe: Manipulate sender ip on TCPCLIENT (port forwarding application with internal packet checks) [modified] Pin
Peter Josefsson Sweden5-May-08 4:11
Peter Josefsson Sweden5-May-08 4:11 
Hi,

This essentially cannot be done, since the sender address is used by the server to send the response packets back to the client. If you fake the sender address, the TCP connection won't even get past the SYN-ACK phase (as the server will attempt to reply to the forwarders SYN packets with a FIN an ACK directly to the client - which will fail in most scenarios as the client won't have a half-open connection matching it). So - getting even the first payload into the server application would fail. This is why simple "spoof attacks" can only cause damage (unless the targets have seriously broken TCP/IP stacks) using connectionless protocols (UDP, ICMP etc). They can't get to any actual data using TCP.

Note that what you "Write()" to the TcpClient socket is NOT a packet. It is a payload. It will be sent in one or more actual packets over a connection established with a two-way initial packet exchange, each of which will be acknowledged or retransmitted by the sender - the client in this case. If you *really* want a one-way only packet transfer you can use UDP (but then you have to build your own acknowledgement/retransmit mechanism). Then, you could in theory spoof the sender IP (but like another poster noted, Windows and/or the framework will most likely not let you).

TCP-based application layer gateways (ALGs - such as those found in firewalls) handle it this way:

1. They keep track of their clients and forward the response traffic to the appropriate client based on the server IP and the port numbers used (as each client get their own sender port allocated by the forwarder - which becomes the receiver port in replies).

2. Some applications (FTP, for instance) insert the IP addresses in the packet payload (protocol commands). In this case, the ALG has to rewrite the commands (replacing the client's IP address and port(s) with its own) and then use method 1 as well.

Some protocols (such as SIP and other telephony applications) have more elaborate methods of handling ALGs - the ALGs become part of the protocol and actually tell the server that they're involved (as in "hi, this is me on this IP address, but I'm actually working on behalf of this guy on this private IP address that you can't see, so please let me know if you want to talk to him and I'll handle it for you"). This increases complexity by a factor of ten and explains why VoIP is sometimes such a royal pain in the a**... Even telephony operatores sometimes can't configure it correctly...

Later,

--
Peter

modified on Wednesday, May 14, 2008 4:18 AM

GeneralRe: Manipulate sender ip on TCPCLIENT (port forwarding application with internal packet checks) Pin
Jan Weltmeyer5-May-08 8:04
Jan Weltmeyer5-May-08 8:04 
QuestionC# asyncallback Pin
AlexPizzano4-May-08 4:53
AlexPizzano4-May-08 4:53 
AnswerRe: C# asyncallback Pin
Judah Gabriel Himango4-May-08 7:40
sponsorJudah Gabriel Himango4-May-08 7:40 
AnswerRe: C# asyncallback Pin
Charith Jayasundara4-May-08 8:01
Charith Jayasundara4-May-08 8:01 
GeneralRe: C# asyncallback Pin
leckey4-May-08 17:29
leckey4-May-08 17:29 
AnswerRe: C# asyncallback Pin
Dave Sexton4-May-08 11:53
Dave Sexton4-May-08 11:53 
QuestionNeed to Internet chat app. Pin
hdv2124-May-08 4:48
hdv2124-May-08 4:48 
AnswerRe: Need to Internet chat app. Pin
Gareth H4-May-08 5:48
Gareth H4-May-08 5:48 
GeneralRe: Need to Internet chat app. Pin
hdv2124-May-08 5:52
hdv2124-May-08 5:52 
GeneralRe: Need to Internet chat app. Pin
Jan Weltmeyer4-May-08 6:03
Jan Weltmeyer4-May-08 6:03 
AnswerRe: Need to Internet chat app. Pin
Charith Jayasundara4-May-08 7:47
Charith Jayasundara4-May-08 7:47 
AnswerRe: Need to Internet chat app. Pin
leckey4-May-08 17:30
leckey4-May-08 17:30 
QuestionDynamic WorkFlow Pin
Thaer Hamael4-May-08 2:15
Thaer Hamael4-May-08 2:15 
AnswerRe: Dynamic WorkFlow Pin
Kevin McFarlane4-May-08 3:25
Kevin McFarlane4-May-08 3:25 
QuestionPhone Diael in C# Pin
E_Gold4-May-08 0:23
E_Gold4-May-08 0:23 
AnswerRe: Phone Diael in C# Pin
Gareth H4-May-08 3:58
Gareth H4-May-08 3:58 
GeneralRe: Phone Diael in C# Pin
E_Gold4-May-08 18:19
E_Gold4-May-08 18:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.