forked from samyk/pwnat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
5,277 additions
and
4 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
0.3-beta - 04/07/2010 - samy | ||
- added support for cygwin | ||
- added support for freebsd | ||
- patch to fix correct source ip on sending icmps on some kernels, thanks to Taka Nori | ||
|
||
0.2-beta - 03/28/2010 - samy | ||
- patch to fix potential segfault, thanks to Mark Landis | ||
|
||
0.1-beta - 01/22/2010 - samy | ||
- initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# | ||
# Project: udptunnel | ||
# File: Makefile | ||
# | ||
# Copyright (C) 2009 Daniel Meekins | ||
# Contact: dmeekins - gmail | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
# Uncomment appropriate one for the system this is compiling for | ||
OS=LINUX | ||
#OS=SOLARIS | ||
#OS=CYGWIN | ||
|
||
CC=gcc | ||
CFLAGS=-Wall -Wshadow -Wpointer-arith -Wwrite-strings -D ${OS} | ||
|
||
ifeq (${OS}, SOLARIS) | ||
LDFLAGS=-lnsl -lsocket -lresolv | ||
endif | ||
|
||
all: pwnat | ||
|
||
# | ||
# Main program | ||
# | ||
OBJS=socket.o message.o strlcpy.o client.o packet.o list.o destination.o udpserver.o udpclient.o | ||
pwnat: pwnat.c ${OBJS} | ||
${CC} ${CFLAGS} -o pwnat pwnat.c ${OBJS} ${LDFLAGS} | ||
|
||
# | ||
# Supporting code | ||
# | ||
strlcpy.o: strlcpy.c common.h | ||
packet.o: packet.c packet.h common.h | ||
list.o: list.c list.h common.h | ||
socket.o: socket.c socket.h common.h | ||
client.o: client.c client.h common.h | ||
message.o: message.c message.h common.h | ||
destination.o: destination.c destination.h | ||
udpclient.o: udpclient.c packet.h list.h socket.h client.h message.h common.h | ||
udpserver.o: udpserver.c packet.h list.h socket.h client.h message.h destination.h common.h | ||
|
||
# | ||
# Clean compiled and temporary files | ||
# | ||
clean: | ||
ifeq (${OS}, CYGWIN) | ||
rm -f pwnat.exe | ||
else | ||
rm -f pwnat | ||
endif | ||
rm -f *~ *.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# | ||
# Project: udptunnel | ||
# File: Makefile.Win32 | ||
# | ||
# Copyright (C) 2009 Daniel Meekins | ||
# Contact: dmeekins - gmail | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
CC=cl.exe | ||
CFLAGS=/nologo /DWIN32 /c | ||
LDFLAGS= | ||
LIBS="c:\Program Files\Microsoft SDKs\Windows\v6.0A\lib\WS2_32.Lib" | ||
|
||
all: pwnat.exe | ||
|
||
OBJS=socket.obj message.obj client.obj list.obj destination.obj udpserver.obj udpclient.obj pwnat.obj xgetopt.obj gettimeofday.obj | ||
pwnat.exe: $(OBJS) | ||
link.exe /NOLOGO /OUT:pwnat.exe $(LDFLAGS) $(OBJS) $(LIBS) | ||
|
||
list.obj: list.c list.h common.h | ||
$(CC) $(CFLAGS) list.c | ||
socket.obj: socket.c socket.h common.h | ||
$(CC) $(CFLAGS) socket.c | ||
client.obj: client.c client.h common.h | ||
$(CC) $(CFLAGS) client.c | ||
message.obj: message.c message.h common.h | ||
$(CC) $(CFLAGS) message.c | ||
destination.obj: destination.c destination.h | ||
$(CC) $(CFLAGS) destination.c | ||
udpclient.obj: udpclient.c list.h socket.h client.h message.h common.h | ||
$(CC) $(CFLAGS) udpclient.c | ||
udpserver.obj: udpserver.c list.h socket.h client.h message.h common.h | ||
$(CC) $(CFLAGS) udpserver.c | ||
pwnat.obj: pwnat.c common.h | ||
$(CC) $(CFLAGS) pwnat.c | ||
xgetopt.obj: xgetopt.c xgetopt.h | ||
$(CC) $(CFLAGS) xgetopt.c | ||
gettimeofday.obj: gettimeofday.c gettimeofday.h | ||
$(CC) $(CFLAGS) gettimeofday.c | ||
|
||
clean: | ||
del *.obj pwnat.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
pwnat, by Samy Kamkar, is a tool that allows any client | ||
behind a NAT to communicate with a server behind a | ||
separate NAT with *no* port forwarding and *no* DMZ | ||
setup on any routers in order to directly communicate | ||
with each other. | ||
|
||
There is no middle man, no proxy, no 3rd party, no UPnP | ||
required, no spoofing, no DNS tricks. | ||
|
||
More importantly, the client can then connect to any | ||
host or port on any remote host or to a fixed host and | ||
port decided by the server. | ||
|
||
Simply put, this is a proxy server that works behind a NAT, | ||
even when the client is behind a NAT. | ||
|
||
pwnat - http://samy.pl/pwnat | ||
by Samy Kamkar | ||
|
||
pwnat is based off of udptunnel by Daniel Meekins: | ||
http://code.google.com/p/udptunnel/ | ||
|
||
usage: ./pwnat <-s | -c> <args> | ||
|
||
-c client mode | ||
<args>: [local ip] <local port> <proxy host> [proxy port (def:2222)] <remote host> <remote port> | ||
|
||
-s server mode | ||
<args>: [local ip] [proxy port (def:2222)] [[allowed host]:[allowed port] ...] | ||
|
||
-6 use IPv6 | ||
-v show debug output (up to 2) | ||
-h show this help and exit | ||
|
||
|
||
EXAMPLE: | ||
|
||
Server side allowing anyone to proxy: | ||
./pwnat -s | ||
|
||
Client wanting to connect to google.com:80: | ||
./pwnat -c 8000 <pwnat.server.com> google.com 80 | ||
|
||
Then, browse to http://localhost:8000 to visit the google! | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
============================================================================= | ||
|
||
UDPTUNNEL README | ||
|
||
Author: Daniel Meekins | ||
Contact: dmeekins - gmail | ||
|
||
Copyright (C) 2009 Daniel Meekins | ||
|
||
============================================================================= | ||
|
||
This project tunnels TCP data through a UDP tunnel. The executable can act as | ||
the server or client. The server acts as a proxy for the client, listening | ||
on a specified UDP port and creating a connection to a TCP server that the | ||
client specifies. The client listens on a TCP port, acting as the server that | ||
some TCP client connects to. The client recevies any TCP data on that port | ||
and sends the data to the udpserver, which sends it to the TCP connection it | ||
made with the desired TCP server. | ||
|
||
|
||
----------------------------------------------------------------------------- | ||
1.) Building | ||
|
||
On *nix systems in Makefile, make sure that the correct value is set for the | ||
"OS" variable. Then just run 'make'. | ||
|
||
On Windows, if using GCC in Cygwin, make sure the "OS" variable is set to | ||
CYGWIN in Makefile and run 'make'. | ||
|
||
If using the VC++ compiler (cl.exe), make sure to be in the "Visual Studio | ||
Command Prompt", or at least have all the environment variables set correctly, | ||
then run 'nmake.exe /f Makefile.Win32'. Also make sure the location of | ||
WS2_32.Lib is specified correctly fo the LIBS variable. | ||
|
||
|
||
----------------------------------------------------------------------------- | ||
2.) Running | ||
|
||
usage: ./udptunnel -<s|c> [-6] <args> | ||
-c client mode (default) | ||
<args>: [local host] <local port> <proxy host> <proxy port> | ||
<remote host> <remote port> | ||
-s server mode | ||
<args>: [host] port [[host]:[port] ...] | ||
-6 use IPv6 | ||
-h show this junks and exit | ||
|
||
To run the server: | ||
udptunnel -s [-6] [host] port | ||
where the port is a UDP port to listen for messages from the udpclient and host | ||
is the address to listen on. Use the -6 option to listen on IPv6 addresses. | ||
Examples: | ||
udpserver -s 4444 | ||
udpserver -s -6 2001::10:3 4444 | ||
|
||
To run the client: | ||
udptunnel -c [-6] [local host] <local port> <proxy host> <proxy port> | ||
<remote host> <remote port> | ||
local host/port - Host and port for the TCP server to listen on. If the host | ||
isn't supplied, it will listen on all available addresses. | ||
proxy host/port - Host and port that udpserver is listening on. | ||
remote host/port - Host and port to forward the received TCP data to. The host | ||
is relative to the proxy machine (e.g. specifiying 127.0.0.1 | ||
is the proxy machine itself). | ||
Use the -6 option to listen and connect using IPv6 addresses. | ||
|
||
Example for tunneling ssh data through the tunnel between two computers with IP | ||
addresses 192.168.1.2 (client) and 192.168.1.1 (server): | ||
|
||
server# ./udptunnel -s 192.168.1.1 4444 | ||
client# ./udptunnel -c 127.0.0.1 3333 192.168.1.1 4444 127.0.0.1 22 | ||
client# ssh -p 3333 [email protected] | ||
|
||
Specified destination list: | ||
After the args in server mode, a list of hosts and ports can be included to | ||
control who the client tries to connect to. Current this doesn't work with IPv6 | ||
and no names are translated yet, so the destination host used in the client | ||
must be the same string as that used in the list. | ||
|
||
This code has been tested and works on Linux, Solaris 10 x86, and Cygwin (but | ||
requires the IPv6 extension - http://win6.jp/Cygwin/index.html). Please send | ||
any bugs or issues to the contact listed above. |
Oops, something went wrong.