Trustwave SpiderLabs Uncovers Ov3r_Stealer Malware Spread via Phishing and Facebook Advertising. Learn More

Trustwave SpiderLabs Uncovers Ov3r_Stealer Malware Spread via Phishing and Facebook Advertising. Learn More

Services
Capture
Managed Detection & Response

Eliminate active threats with 24/7 threat detection, investigation, and response.

twi-managed-portal-color
Co-Managed SOC (SIEM)

Maximize your SIEM investment, stop alert fatigue, and enhance your team with hybrid security operations support.

twi-briefcase-color-svg
Advisory & Diagnostics

Advance your cybersecurity program and get expert guidance where you need it most.

tw-laptop-data
Penetration Testing

Test your physical locations and IT infrastructure to shore up weaknesses before exploitation.

twi-database-color-svg
Database Security

Prevent unauthorized access and exceed compliance requirements.

twi-email-color-svg
Email Security

Stop email threats others miss and secure your organization against the #1 ransomware attack vector.

tw-officer
Digital Forensics & Incident Response

Prepare for the inevitable with 24/7 global breach response in-region and available on-site.

tw-network
Firewall & Technology Management

Mitigate risk of a cyberattack with 24/7 incident and health monitoring and the latest threat intelligence.

Solutions
BY TOPIC
Microsoft Exchange Server Attacks
Stay protected against emerging threats
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
About Us
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Security Operations Platform
Trustwave Security Colony
Partners
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats
SpiderLabs Blog

Hooked on Packets: Reading PCAPs for D Students - Preview

SOURCE Boston is coming up in April, and Mike Ryan and I are giving a presentation about making packet analysis easier for the masses. One of the challenges with building new protocol parsers for tools such as Ettercap and Wireshark is many of these parsers are written in C. C is very fast and powerful, however you run the risk of introducing vulnerabilities in the software. And, for folks who aren't fluent C programmers, building these parsers can be intimidating.

So, what are we going to do to change this? One of the pieces we've been working on is trying to merge Lua into Ettercap. We did a presentation at Derbycon last year about how we planned to do this, and now we have some practical uses. We're going to take a look at how to build easy to use scripts, similar to the Nmap NSE scripts, to allow manipulation and parsing of data that would otherwise require C code.

I wrote a quick example that we will examine in more detail during our presentation. The example focuses on tracking HTTP traffic on the network or in captures.

Why do we care about HTTP requests? On a penetration test, we may use a MitM attack to target groups of individuals and watch their requests in order to identify interesting targets for session theft or other attacks. Another good example of when this is useful is when looking at malware. We may want to determine what requests malware is making, where it's being redirected to, and even watch for beaconing requests.

It turns out, doing these things with existing tools can be pretty cumbersome. Right now, you could try to match requests and replies in tcp dump. But, if there are multiple simultaneous requests, it gets trickier. You can do the same thing in Wireshark and Tshark, but you have to do a lot of clicking around-- or write some lua tore-assemble the sessions and then track down the data.

Our solution adds a basic registry to Ettercap. So, you can store session data. To create a session we can do something like this:

-- Get session key for tracking req->reply pairs local session_id = http.session_id(p,hobj)

-- We have a session, lets get our registry space local reg = ettercap.reg.create_namespace(session_id)

Now, we have a local registry that is unique to our session.We can use this registry to store session data. One thing we may want to do is extract request data, and store it until the response comes in so we can match them up. To do something like this, we can parse the packet:

-- Parse the packet (p) and retrieve the http data

local hobj = http.parse_http(p)

If we are looking at a request, we want to store the request for retrieval in the registry for when we see the response:

if hobj.request then

reg.request = hobj

If we saw a response, then we just want to print it out:

      -- Get the status code      local code = hobj.status_code      -- Build the request URL      -- If we have a 2XX or 4XX or 5XX code, we won't need to log redirect      -- so just log the request and code      if code >= 200 and code < 300 or code >= 400 then         ettercap.log("HTTP_REQ: %s:%d -> %s:%d %s %s %d (%s)\n",            packet.dst_ip(p),            packet.dst_port(p),             packet.src_ip(p),             packet.src_port(p),             reg.request.verb ,reg.request.url , hobj.status_code, hobj.status_msg)

Dealing with the request and matching response is easy in this model. And we can easily add parsers for other types of traffic that aren't supported by Ettercap and Wireshark. When you put it all together, it gets very easy to track requests made by a browser in a MitM attack or from network capture files. Here's an example of how the initial requests from viewing Slashdot look, using our version of Ettercap with Lua modules enabled:

7982_113ba48d-f527-4f8c-b4f5-b72446628b7b

Note: we are printing both source and destination, the full request, status code, and in the case of a redirect, where the user was sent. This is just a brief example of the types of things that are going to be easy to build with this framework.

We will be releasing the source code for a patched Ettercap along with sample modules at SOURCE Boston.

If you're interesting in helping out or learning more, come see us and the other SpiderLabs folks at SOURCE Boston and chat with us about your ideas.

Latest SpiderLabs Blogs

Breakdown of Tycoon Phishing-as-a-Service System

Just weeks after Trustwave SpiderLabs reported on the Greatness phishing-as-a-service (PaaS) framework, SpiderLabs’ Email Security team is tracking another PaaS called Tycoon Group.

Read More

Physical Address Strangeness in Spam

Ten years ago, Congress passed the "CAN-SPAM Act" (also known as theYou-CAN-SPAM Act, since it defined legal spam and supersedes any stricter state-antispam laws). One of the provisions of the act is...

Read More

Trustwave SpiderLabs Uncovers Ov3r_Stealer Malware Spread via Phishing and Facebook Advertising

During an Advanced Continual Threat Hunt (ACTH) investigation that took place in early December 2023, Trustwave SpiderLabs discovered Ov3r_Stealer, an infostealer distributed using Facebook...

Read More