PyScript Domains > 72 Char.

Last night I was reading one of the go-to blue team compendiums, Blue Team Handbook, by Don Murdoch and it was going over the anomalies that one should look out for when it comes to analyzing DNS traffic. I've also been trying to get my novice python skills to a place where I can comfortably automate tasks for both ease and efficiency.


So I decided I'd try put together a script to extract domain names > 7s characters in length and another script where I extracted the domain names and do a whois lookup to see if they were created < 7 days ago. The whois script i've been having some issues with, but the script focusing on domain length I wanted to post here for anyone knew to python and infosec that man want to get some ideas for themselves.


I know all of this can be done with Tshark, Wireshark, Zeek or any other analyzer, but this was mostly for practice.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image


# DomainLength Script

import pyshark


def extractDomains(pcap_file):

domains = set()

cap = pyshark.FileCapture(pcap_file, display_filter='dns.qry.name')

for packet in cap:

try:

domain = packet.dns.qry_name.lower()

domains.add(domain)

except AttributeError:

pass

return domains


def main():

pcap_file = 'sample.pcap'

domains = extractDomains(pcap_file)

if not domains:

print("No domains found in the pcap!!")

return


bigDomains = [domain for domain in domains if len(domain) > 72]

if not bigDomains:

print("No domains > 72 characters!")

else:

print("Domains > 72 characters:")

for domain in bigDomains:

print(domain)


if __name__ == "__main__":

main()


Happy Hunting!

Daniel McNally

Cybersecurity and Information Assurance Analyst

1 年

Hmm. Have to edit this. All indentation was removed upon publishing.

回复

要查看或添加评论,请登录

Daniel McNally的更多文章

  • Project 1 - DVWA

    Project 1 - DVWA

    During the latest FXBG Hackers meeting, a newcomer attended for the second time. He expressed an interest in…

  • Security Analyst Notes: Things to Remember

    Security Analyst Notes: Things to Remember

    Over the last two years during my training, I've been taking notes along the way on all different topics that have been…

    7 条评论
  • Malware Analysis Notes: Putty.exe

    Malware Analysis Notes: Putty.exe

    I finally was able to get back around to working on the PMAT course by, HuskyHacks and TCM Security. These are my notes…

    1 条评论
  • Snort 3 vs MiTM Attacks

    Snort 3 vs MiTM Attacks

    Executive Summary: There are pros and cons when using Snort's Intrusion Prevention and Intrusion Detection System…

  • Manual Log Parsing with Cut, AWK and Python

    Manual Log Parsing with Cut, AWK and Python

    This will be a quick tutorial aimed at people who are infosec newbies or are new to Linux in general that are…

    1 条评论
  • Blue Team CTF: Warzone 1

    Blue Team CTF: Warzone 1

    To continue to work on my ability to parse logs and sniff out possible IOC's, I will be tackling another blue team CTF…

  • Splunk BOTSv3 AWS & WINEvent

    Splunk BOTSv3 AWS & WINEvent

    AWS S3 Bucket Challenge Today I will be finishing up my Splunk course with 2 more blue team CTFs. The first challenge…

    1 条评论
  • Splunk BOTSv3 Web & OneDrive

    Splunk BOTSv3 Web & OneDrive

    The past week I’ve been spending most of my time trying to complete a Splunk learning path to gain an understanding of…

  • CTF: SNORT Basics Pt. 1

    CTF: SNORT Basics Pt. 1

    Today I will be running through a blue team CTF focused on using the IDS/IPS Snort. Snort can be used both passively…

    5 条评论
  • Malware Stager Deobfuscation

    Malware Stager Deobfuscation

    During a recent challenge, I received an obfuscated malware stager that was a PowerShell script that needed…

社区洞察

其他会员也浏览了