I made a quick presentation on basic static and dynamic malware analysis.
When exploring binary files it is often useful to run strings to look for interesting data. I’ve written a simple python script to analyze strings output for IP addresses and domain names.
This script will analyze the output of the strings command and look for IP addresses and domain names. When a potential IP address is found it will attempt a reverse lookup. When a potential domain name is found it will attempt to resolve the name to an IP address.
$ strings FileName | python strings-analysis.py
You can find the code on my Github.
A DGA is a Domain Generating Algorithm. These algorithms provide malware with new domains when connecting back to a C2 server. Both the C2 server and the client need to implmement the same DGA to keep in sync for constant communication at any given time.
DGAs are a nessessary to avoid blacklisting which hinders the operation of the malware. Without a DGA a new version of malware would need to be deployed when the domain is discovered and blocked. A well written DGA is hard to determine and switches on a regular interval to avoid blacklisting keeping the C2 communication up and running. The result of a DGA is an AGD or algorihimly generated domain. The constant changing of domains is often referred to as Domain Fluxing.
Finding DGAs in malware is often the combination of reverse engineering and dynamic analysis. Reverse engineering will alllow you to determine seed values and top level domains used to generate the domains. The goal is to reverse engineer the algorithm to predetermine domains for blacklisting. Alternately, you can run the malware and log network traffic reviewing the generated domains, and attempt to reverse engineer the algorithm which generated them.
In summary, DGAs provide malware authors a method to avoid detection and blacklisting of there C2 channel. Reverse engineering the DGA provides a method for defenders protect their networks from malicious activity. DGA authors will continue to think of new and clever ways of generating domains for C2 connectivity. Potential methods include seeding the algorithms based on trending topics on Twitter, stock market prices, or even the current value of bitcoin. The potential methods are only limited by one’s imagination.
I’ve been exploring high-level malware analysis over the past few weeks. This post is a collection of thoughts and learnings from exploring this area of research.
First things first, you need to setup a lab environment off of your production network to analyze malware samples. I recommend using a virtual machine to acomplish this wether that is virtual box or VMware. You will need a Windows machine running Windows 7 or later depending on your needs.
I have opted for setting up the FLARE VM on Windows as it includes a plethora of utilities to get you started. A number of which I will be breifly discussing in this post.
Make sure to create a snapshot of a clean state once you have your analysis VM configured. You can restore this snapshot when you have completed an analysis session or need to update your system and tools.
It is important to ensure your VM is set to host-only mode when doing analysis to ensure the malware cannot connect to its C2 server or other machines on your network. This will prevent the malware from doing malicious operations that you will want to prevent when analyzing its inner workings.
Setting up FLARE VM is straight forward and to this point the only set of tools I’ve explored on this journey. Download the installer from https://github.com/fireeye/flare-vm and follow the instructions in Readme.md. This will transform your Windows VM into a malware analysis machine giving you the utilities you need to perform both static and dynamic analysis of malware samples.
PE File Format
Windows executables use the portable executable file format, also called the PE file format. These files contain the information required by the Windows loader to manage the wrapped executable code. The file begins with a header that contains information about the code, type of application, required library functions, and space requirements. Reviewing the PE file for this information gives us a great look at what the program may do. Looking at the required libraries and functions can give hints as to the functionality of the application. Reviewing space requirements may indicate if we are dealing with a packed executable. This is a good place to start when doing basic static analysis.
The four commonly found file sections include the following:
- Contains the instructions that the CPU executes
- This should be the only section that can execute
- Other sections include supporting information
- Contains import and export information
- Can also be used to store other read-only data
- Sometimes different compilers will create a .idata and .edata for import and export information
- Contains global information accessible from anywhere within the program
- Contains resources used by the application such as icons, menus, images, and strings.
While exploring your malware samples you may encounter packed executables. This is fairly common for malware authors to pack executables for both obsucaction and to avoid detection by scanners.
A couple tips on detecting if you are working with a packed executable.
- Running strings returns no human readable text
- The import address table is very sparse
- Section headers have declared sections with RAW Size of 0
When you encounter a packed executable there are a few tools included in the FLARE VM to help you unpack the exe.
Take a look at the following utilities to get started.
- CFF Explorer (supports UPX unpacking)
Tools for Basic Static Analysis
- Resource Hacker
Tools for Basic Dynamic Analysis
- Network monitoring
I’m going to dive a bit into FakeNet-NG as I found it particularly useful. FakeNet-NG is a dynamic network analysis tool for malware analysis. It allows you to intercept and redirect all or specific network traffic while simulating legitimate network services. What does this mean? While you are running in host-only mode on your VM, the malware cannot reach out to its C2 server or other network services. FakeNet-NG steps in and provides network services for the malware to communicate with providing fake network connectivity for your malware sample. During this process, FakeNet-NG will create a pcap file of all the traffic captured during the execution of the malware sample allowing you to dig deeper into what C2 servers or other network resources the malware is communicating with. This allows you to profile the malware functionality in safe manor.
For more information on FakeNet-NG visit https://github.com/fireeye/flare-fakenet-ng and read the provided documentation.
I will continue to update this post with additional information as my research progresses. I hope you found this useful.
You can not connect to ssh over wifi with the 10.2 jailbreak. You need to ssh over USB. They are several options but the easiest is to use iproxy.
- Install iproxy
brew install libimobiledevice
- On the terminal run the following command.
iproxy 2222 22
This will enable you to forward all traffic from port 2222 to port 22 over USB
- Now you can connect to the iPhone by running ssh
ssh root@localhost -p 2222
Notice you connect to localhost not the ip address of your phone. If everything went well, you should be presented with the ssh prompt.
After setting up a proxy and configuring a device, normally you can navigate to http://burp and download the certificate for installation. This did not work for me when running Android 6.0.1.
To install the certificate on an Android device I had to export the certificate from Burp in DER format. After that I was able to import the certificate with out any problems.
- Open Burp
- Navigate to Proxy -> Options -> Import / export CA certificate
- Select Certificate in DER format
- Export the certificate
- Copy the certificate to the Android device
- Install the certificate by navigating to Settings -> Wi-Fi – More options -> Advanced -> Install certificates
- Select the certificate and give it a name
Once the certificate is installed you can proxy SSL/TLS traffic as expected.
I have disclosed three vulnerabilities in the Vonage (Grandstream) HT802. I haven’t received a response from Vonage. These vulnerabilities can be chained to inject persistent XSS in the Basic Settings screen of the device.
Update: I have the following received CVEs for these vulnerabilities:
1.) Cross-Site Request Forgery (CSRF) vulnerability in the login screen (/cgi-bin/login) allows an attacker to log into a target Vonage device. (CVE-2017-165635)
POC Verified in Firefox 56.0 on macOS
2.) Cross-Site Request Forgery (CSRF) vulnerability in the Basic Settings screen allows an attacker to modify system settings. (CVE-2017-16563)
POC Verified in Firefox 56.0 on macOS
3.) Stored Cross-site scripting (XSS) vulnerability in cgi-bin/config2 in Vonage HT802 allows remote authenticated users to inject arbitrary web script or HTML via the DHCP vendor class ID field (P148). (CVE-2017-16564)
POC Verified in Firefox 56.0 on macOS
These three vulnerabilities can be chained to inject a persistent XSS payload into the Basic Settings page.
Update: this has been assigned CVE-2017-15885.
I have found a vulnerability in the Axis 2100 Network Camera running 2.03 firmware. Vulnerability has been disclosed to the vendor but the camera is no longer supported.
POC Verified on Firefox 55.0.3:
Four rules that are core to the use of public key cryptography and digital signatures:
- When encrypting a message, use the recipient’s public key
- When decrypting a message that you have received, use your private key
- To digitally sign a message that you are sending to someone, use your private key
- To verify the signature on a message sent to you by someone, use the sender’s public key