Skip to content

Commit

Permalink
Added examples and edited usage
Browse files Browse the repository at this point in the history
easymoney322 committed Jun 21, 2023

Verified

This commit was signed with the committer’s verified signature.
easymoney322 EasyMoney322
1 parent e1ae6f7 commit 5d73926
Showing 2 changed files with 29 additions and 11 deletions.
14 changes: 7 additions & 7 deletions LaunchOptionsHandling.cpp
Original file line number Diff line number Diff line change
@@ -9,10 +9,10 @@
<< "-TCP - Specifiy to create TCP mapping instead of UDP (Optional)" << std::endl \
<< "-BOTH - Specify to create both TCP and UDP mappings (Optional)" << std::endl \
<< "-GP xxxxx - Port that NAT-PMP-capable gateway is listening on. (Optional, defaults to 5351)" << std::endl \
<< "-GW xxx.xxx.xxx.xxx - IPv4 of the GateWay in broadcast domain (Optional, defaults to IPv4 address of the gateway on the interface)" << std::endl \
<< "-DM xx:xx:xx:xx:xx:xx - Destination (target's) MAC (Optional, but host must be reachable with NetBios)" << std::endl \
<< "-GM xx:xx:xx:xx:xx:xx - Gateway MAC (Optional, but gateway must be reachable with NetBios)" << std::endl \
<< "-SM xx:xx:xx:xx:xx:xx - MAC of output interface (Optional, if host in the same subnet as the target)" << std::endl;
<< "-GW xxx.xxx.xxx.xxx - IPv4 of the NAT-PMP Gateway (Optional, defaults to IPv4 address of the gateway on the interface)" << std::endl \
<< "-DM xx:xx:xx:xx:xx:xx - Destination (target's) MAC address (Optional, but host must be reachable with NetBios)" << std::endl \
<< "-GM xx:xx:xx:xx:xx:xx - MAC address of Gateway in the broadcast domain, that is the next hop (Optional, but gateway must be reachable with NetBios)" << std::endl \
<< "-SM xx:xx:xx:xx:xx:xx - MAC address of output interface (Optional, if host in the same subnet as the target)" << std::endl;

std::vector<std::string> launcharguments;
int LaunchOptionsProcessing(int localargc, char* localargv[])
@@ -120,7 +120,7 @@ int LaunchOptionsProcessing(int localargc, char* localargv[])
if (true == has_option(launcharguments, "-DM")) //Destination MAC argument handling
{
mac_testerproto("-DM", DMAC);
std::cout << "Destination MAC is set to " << DMAC << ";" << std::endl;
std::cout << "Destination MAC address is set to " << DMAC << ";" << std::endl;
}
else
{
@@ -131,7 +131,7 @@ int LaunchOptionsProcessing(int localargc, char* localargv[])
if (true == has_option(launcharguments, "-GM")) //Gateway MAC argument handling.
{
mac_testerproto("-GM", GWMAC);
std::cout << "GateWay MAC is set to " << GWMAC << ";" << std::endl;
std::cout << "Gateway MAC address is set to " << GWMAC << ";" << std::endl;
}
else
{
@@ -142,7 +142,7 @@ int LaunchOptionsProcessing(int localargc, char* localargv[])
if (true == has_option(launcharguments, "-SM")) //Source MAC argument handling
{
mac_testerproto("-SM", SMAC);
std::cout << "Source MAC is set to " << SMAC << ";" << std::endl;
std::cout << "Source MAC address is set to " << SMAC << ";" << std::endl;
}
else
{
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -24,12 +24,30 @@ If you run the program behind NAT or from different subnet, the work depends on
* -TCP - Specifiy to create TCP mapping instead of UDP (Optional);
* -BOTH - Specify to create both TCP and UDP mappings (Optional);
* -GP xxxxx - Port that NAT-PMP-capable gateway is listening on. (Optional, defaults to 5351);
* -GW xxx.xxx.xxx.xxx - IPv4 of the GateWay (Optional, defaults to IPv4 address of the gateway on the interface);
* -DM xx:xx:xx:xx:xx:xx - Destination (target's) MAC (Optional, but host must be reachable with NetBios);
* -GM xx:xx:xx:xx:xx:xx - Gateway MAC (Optional, but gateway must be reachable with NetBios);
* -SM xx:xx:xx:xx:xx:xx - Out source MAC (Optional, if host is in the same subnet as the target);
* -GW xxx.xxx.xxx.xxx - IPv4 of the NAT-PMP Gateway (Optional, defaults to IPv4 address of the gateway on the interface);
* -DM xx:xx:xx:xx:xx:xx - Destination (target's) MAC address (Optional, but host must be reachable with NetBios);
* -GM xx:xx:xx:xx:xx:xx - MAC address of Gateway in the broadcast domain, that is the next hop (Optional, but gateway must be reachable with NetBios);
* -SM xx:xx:xx:xx:xx:xx - MAC address of output interface (Optional, if host is in the same subnet as the target);


# Examples
In most of the cases these will be enough:
* UDP:
`NAT-PMP-Spoofer.exe -DA 192.168.1.228 -PH 9999`
This command will try to create UDP mapping on found gateway for host (.1.228), forwarding **UDP** traffic to host's port 9999 from the same UDP port on the Gateway.

* TCP:
`NAT-PMP-Spoofer.exe -DA 192.168.1.228 -PH 80 -PO 8080 -TCP`
This command will try to create TCP mapping on found gateway for host (.1.228), forwarding **TCP** traffic from port 8080 on the gateway to port 80 on host.

Both commands will create mappings that will last 7200 seconds (2 hours). Please note that according to RFC [6886](https://datatracker.ietf.org/doc/html/rfc6886/), "The NAT gateway MAY reduce the lifetime from what the client requested". Also, according to this RFC, some NAT-PMP-capable gateways may reject requests if time isn't set to zero.

Both commands requrie additional data that will be fetched with mechanisms such as ARP-requests or win32 API.

If, for some reason, the required data cannot be fetched, user must provide it manually with launch arguments.
`NAT-PMP-Spoofer.exe -DA 192.168.1.228 -DM b1:6b:00:b5:ba:be -PH 80 -PO 8080 -TCP -GW 192.168.1.1 -GM c1:5c:0d:06:1e -SM ba:be:de:fe:c8:ed -T 0`
Providing additional data with launch arguments also increases speed of the programm, while also reducing network presence.

# Q&A
* Q: Can it create TCP mappings?

0 comments on commit 5d73926

Please sign in to comment.