This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.9 | |
import subprocess | |
from subprocess import Popen | |
command=''' | |
cat /Users/christopher/Desktop/ip_data.log | grep -E -o "(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})" | sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n | uniq -c | sort -rn | head -n 10 | |
''' | |
process=Popen(command,shell=True,stdout=subprocess.PIPE) | |
result=process.communicate() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Extracts top 10 most frequent ipv4 addresses from file | |
#Where grep options include '-E' to specify an extended regular expression pattern, | |
#in this case for ipv4, followed by '-o' to print only the matching parts of lines. | |
#Where sort options include '-t' to denote . as the fields separator / delimiter, | |
#'-k' to indicate the number of expected key fields to sort from left to right, | |
#and a further '-rn' option combination to sort results in reverse numerical order. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.9 | |
import asyncio | |
import re | |
from pathlib import Path | |
import aiofiles | |
directory = '/Users/christopher/Desktop/' | |
pattern = re.compile(r"(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.9 | |
import subprocess | |
import getpass | |
def get_keychain_pass(pw_item_name): | |
'''Retrieves the password value for a specified keychain item using subprocess.run() and getpass.getuser()''' | |
return subprocess.run(['security', 'find-generic-password', '-w', '-a', getpass.getuser(), '-s', pw_item_name], | |
stdout=subprocess.PIPE).stdout.decode('utf-8') |