Building Cyber Security Tools Using Python

Cleared Workforce is a specialty search firm focused on security-cleared Talent Recruitment for Government Contractors.

100+

product reviews of trending tech

100+

tech written guides for users

100+

tech tools in our tool database


import socket

def scan_port(ip, port):
    try:
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.settimeout(1)
        result = sock.connect_ex((ip, port))
        if result == 0:
            print(f"Port {port} is open on {ip}")
        sock.close()
    except Exception as e:
        print(f"An error occurred: {e}")

# Usage example
target_IP = '192.168.1.1'
for port in range(20, 25):
    scan_port(target_IP, port)
from scapy.all import *

# Create a network packet
packet = IP(dst="192.168.1.1")/TCP(dport=80)
# Send the packet
send(packet)
import requests

response = requests.get('https://example.com')
print(response.text)

import pandas as pd
import matplotlib.pyplot as plt

# Sample data
data = {'hours': [1, 2, 3, 4, 5], 'attacks': [10, 15, 20, 25, 30]}
df = pd.DataFrame(data)

# Plotting
plt.plot(df['hours'], df['attacks'])
plt.xlabel('Hours')
plt.ylabel('Number of Attacks')
plt.title('Cyber Attacks Frequency')
plt.show()
from cryptography.fernet import Fernet

# Generate a key
key = Fernet.generate_key()
cipher_suite = Fernet(key)

# Encrypt some data
text = b"Hello, World!"
cipher_text = cipher_suite.encrypt(text)
print(f"Cipher text: {cipher_text}")

# Decrypt the data
decrypted_text = cipher_suite.decrypt(cipher_text)
print(f"Decrypted text: {decrypted_text}")
from sklearn.ensemble import IsolationForest
import numpy as np

# Sample data: [normal, normal, anomaly, normal, anomaly]
data = np.array([[10], [12], [1], [11], [0]])

# Train the model
clf = IsolationForest(random_state=42)
clf.fit(data)

# Predict the anomalies
predictions = clf.predict(data)
print(predictions)  # -1 indicates an anomaly

Interested in learning how we can help you?

Cleared Workforce
Expertise Driven Recruitment

We deliver candidates that power mission success.

Looking
for talent?


Looking
for WORK?



EXPERTISE-DRIVEN RECRUITMENT.