Skip to main content

Wireshark cheat sheet for malware analysis, CTF and so on

http.request or dns or tls.handshake.type= =1 

From the above filter result, we can select host and server name and apply as column. or we can do the following. 

Making custom column for malware analysis:

edit menu > preference > appearance > columns > +

Title: Host    Type: Custom    Fields: http.host

Title: Server Name    Type: Custom    Fields: tls.handshake.extensions_server_name


Changing time display:

View>Time Display Format>UTC Date and Time of Day (1970-01-01 01:02:03.123456) Ctrl+Alt+7

then View>Time Display Format>Seconds


Customize filter: As per brad duncan paloalto unit 42 lession

Type this filter keyword:

(http.request or tls.handshake.type eq1) and !(ssdp) in the display filter then save it by clicking the right most + sign. Then give a simple label name as basic. 

or old wireshark packet, you need to use ssl instead of tls.

(http.request or ssl.handshake.type eq1) and !(ssdp) in the display filter then save it by clicking the right most + sign. Then give a simple label name as basic.  

(http.request or tls.handshake.type eq1 or tcp.flags eq 0x0002) and !(ssdp) in the display filter then save it by clicking the right most + sign. Then give a simple label name as basic+. 

(http.request or tls.handshake.type eq1 or tcp.flags eq 0x0002 or dns) and !(ssdp) in the display filter then save it by clicking the right most + sign. Then give a simple label name as basic+dns.


For Adding host or server name column:

Go to column preference. Add the column. Give it a name as host. Then from the drop down select custom. Then type the below keyword:

http.host or tls.handshake.extensions_server_name

or

http.host or ssl.handshake.extensions_server_name


Adding TLS Pre-Master secret key:

Edit>Preferences>Protocol>TLS


ICMP data tunneling:

Statistics>Protocol Hierarchy   (observer percent packet column)

Check file menu>export objects > http to see, any icmpsh.exe tool is downloaded or not. 

During data exfiltration via icmp, the data size will be higher than the usual. so apply filter as,

icmp and data.len>60

frame contains "gmail.com"

strings icmp_tunneling.pcapng | grep -i gmail

strings -n 8 icmp_tunneling.pcapng | grep -i gmail


Detecting port scan, brute force and flooding attack using wireshark:

capinfo capture.pcapng (giving some important info about the pcap)

Brute force:

ftp (type ftp in display filter in order to detect ftp brute force)

Search for packets where info column is written as Login Successful

frame contains "incorrect"

frame contains "successful"

strings -n 8 filtered.pcapng | grep -i "successful"

So we come to an conclusion that, 192.168.6.2 our ftp server and malicious user from source ip 10.99.99.99 tried to ftp brute force. 

Port scan detection:

Nmap is a most popular tool for enumerating ip and port numbers along with other informations. The main characteristics of nmap is, attacker will start scanning the target network or server to see how many ports are open in the remote server. 

If you see in any packet that majority of the traffic are coming from different public ip to port 80 on the web server of 192.168.6.2 then this is not nmap behavior. Also this server 192.168.6.2 will give reply as source to those http request. Also previously we found that 10.99.99.99 was the brute force attacker ip. so we can filter out all of this. Then we can catch the nmap port scanner culprit.

! ip.addr = = 10.99.99.99 && ! tcp.port = = 80 && ! ip.src = = 192.168.6.2


Flooding detection:

The motive of flooding attack is make the server unresponsive. How you can make sure some flooding or ddos attack is happening in your network? Destination will be same and source will be multiple. They randomize source ip using a tool hping3. We can filter out our last two attackers ip address and we know our web server is at 192.168.6.2 so we can filter this ip as source as well because this ip will reply in response with those web request at port 80. We dont need to see those reply packet as source. We can not filter tcp.port = = 80 because the hit is coming at 80 port. If we filter that then we can not detect the actual one.

! ip.addr = = 10.99.99.99 && ! ip.addr = = 10.66.66.66 && ! ip.src = = 192.168.6.2

 

Finding username and password in http POST request:

When you need to find password in http 80 plain text protocol, then http POST method would help in wireshark packet capture. 

http.request.method = = POST && frame contains "Mozellobel-EiZ"

or 

http.request.method = = POST && http.file_data contains "Mozellobel-EiZ"

You should see some packets that contains password for Mozellobel-EiZ user. Now question is in which packet should i look for? Always look for last packet. 

We can also find password by leveraging strings and grep command. 

strings -n 9 capture3.pacpng | grep -i mozellobel-eiz

Check the last entry. 


In order to find hostname or computer name and username in wireshark:

filter with, kerberos.CNameString keyword. Then choose any packet>expand Kerberos>expand tgs-rep> expand cname>expand cname-string>right click on CNameString and select apply as column. 

NBNS and dhcp protocol filter will help sometimes when DC is not involved.

 

ssh private key finding:

filter with: frame contains "private" or "RSA"    filter with tcp protocol and see last packets as well.

take the key and save in a file say id. in this id file we saved the private key and we need to provide it id file during ssh connect using -i switch. 

ssh -i id username@servername


If told attacker or somebody search for some files in the web:

Then filter with http packets and GET request. http.request.method eq GET

Also keep an eye on the file name. Filter with that as well like frame contains "file name"


During extraction of files:

MZ --> for exe

ELF --> for Bin


For persistency establishment:

search with cron jobs in packet. 


QuickBot smtp packet:

(http.request or tls.handshake.type eq 1 or (tcp.port eq 65400 and tcp.flags eq 0x0002) or smtp or pop or imap) and !(ssdp) 


Finding the SYN packets with https requests:

tcp.flags == 0x0002 || tcp.flags == 0x00c2 || http.request || ssl.handshake.type == 1


Sometimes we need to examine wireshark in unintended way. Meaning use grep to find out the flag or export files or use binwalk -e pcapng or foremost command. Then examine the output files to get the flag. 



Avi






 

 



Comments

Popular posts from this blog

API hacking lab setup

 Follow the commands to install and configure API hacking lab: 1. Install kali linux and update all the packages.  apt update -y apt upgrade -y or apt dist-upgrade -y or apt full-upgrade -y If you face any problem regarding update, install cloud flare warp in the host machine, then again start updating packages in your kali vm.  2. Install and configure burpsuite professional.  Open burpsuite and go to Extender tab. Click on BAppStore. Search for Autorize extension, It will help us to automate authorization testing. Click on Download Jython. From Jython website click on Jython standalone and save it. Go to Extender > Options and under python environment select the jython jar file that you just downloaded. Now again go to BAppStore and re-search for Autorize extension. You will see Install option this time after selecting Autorize extension. Install it. You will see all the installed extensions under Extender > Extensions tab.  3. Install foxy proxy to prox...

Installing Codename SCNR web application scanner on ubuntu | kali

  Perform the following steps from a non-root user. We will go for manual installation.  https://github.com/scnr/installer?tab=readme-ov-file#manual-installation https://github.com/scnr/installer/releases wget https://github.com/scnr/installer/releases/download/v1.7.3/scnr-v1.7.3-linux-x86_64.tar.gz   (Download using normal user) tar -xvzf scnr-v1.7.3-linux-x86_64.tar.gz cd scnr-v1.7.3 cd bin Now go to their website ( https://ecsypno.com/products/scnr ) and subscribe for community edition license from your official email.  ./scnr_activate 6XQ97FW3LVBECD0UJ5H214 ./scnr https://www.example.net/Login.aspx --system-slots-override Now they generate .ser format report after testing the application by default which is hard to read. We need html report. So for example, to generate an HTML report: ./scnr_reporter --report=html:outfile=my_report.html.zip /home/user/.scnr/reports/report.ser Avi

Install Nessus from docker

Docker installation. Give the below commands one by one. apt install docker-cli or apt install docker.io After the installation is complete, if you are inside wsl then give this command to start docker, because inside wsl systemd (systemctl) does not work: service docker start WSL troubleshooting : If the above command " service docker start " does not work then use below command: dockerd (It may not work if any previous docker process is running. It will show you pid of that process. Use this command to kill that process " kill -9 pid " and run dockerd command again) If " docker ps -a " giving error like " Cannot connect to the Docker daemon at unix:///run/podman/podman.sock. Is the docker daemon running? " This is because you may installed podman-docker package. If you remove the package still you will get this error but you should remove the package. Then issue this command: env | grep -i docker DOCKER_HOST=unix:///run/podman/podman.sock   --...