This file contains 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
# Use match with an explicit variable | |
$mystr = "hello to the world"; | |
($one, $two) = $mystr =~ /(\w+)[^\w](\w+)/; | |
print("$one\n"); | |
print("$two\n"); | |
# Use with implicit variable $_ | |
$_ = "hello to the world"; | |
($one, $two) = /(\w+)[^\w](\w+)/; | |
print("$one\n"); |
This file contains 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
# Uncompress a block of text | |
import zlib | |
def gzinflate(gzippedString): | |
return zlib.decompress(gzippedString, -15) | |
This file contains 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
# Encode ASCII to hex | |
'password'.encode("hex") | |
# Decode hex to ASCII | |
'70617373776f7264'.decode("hex") | |
# >>> '\x70\x61\x73\x73\x77\x6f\x72\x64' | |
# 'password' |
This file contains 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
import socket | |
import struct | |
def ip2dec(ip): | |
packedIP = socket.inet_aton(ip) | |
return struct.unpack("!L", packedIP)[0] | |
def dec2ip(dec): | |
return socket.inet_ntoa(struct.pack("!L", dec)) |
This file contains 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/python | |
import string | |
# Given startString, this loops through rot(n) until it is un-rotted back to original | |
# rot_alpha courtesy of http://eddmann.com/posts/implementing-rot13-and-rot-n-caesar-ciphers-in-python/ | |
def rot_alpha(n): | |
from string import ascii_lowercase as lc, ascii_uppercase as uc | |
lookup = string.maketrans(lc + uc, lc[n:] + lc[:n] + uc[n:] + uc[:n]) | |
return lambda s: s.translate(lookup) |
This file contains 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/python | |
#-*- coding: utf-8 -*- | |
# For demoing emoji in python | |
mypoo='💩' | |
print('{}'.format(mypoo)) | |
print(u'\U0001F4A9') |
This file contains 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 | |
echo Script name is $0 | |
echo Arguments are ${@} | |
This file contains 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/python | |
import urllib2 | |
import simplejson as json | |
url = 'http://ipinfo.io/json' | |
ipinfo = urllib2.urlopen(url).read() | |
jIP = json.loads(ipinfo) | |
print jIP |
This file contains 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/python | |
import os | |
eicar_file="eicar_output.txt" | |
eicar_string='\x58\x35\x4F\x21\x50\x25\x40\x41\x50\x5B\x34\x5C\x50\x5A\x58\x35\x34\x28\x50\x5E\x29\x37\x43\x43\x29\x37\x7D\x24\x45\x49\x43\x41\x52\x2D\x53\x54\x41\x4E\x44\x41\x52\x44\x2D\x41\x4E\x54\x49\x56\x49\x52\x55\x53\x2D\x54\x45\x53\x54\x2D\x46\x49\x4C\x45\x21\x24\x48\x2B\x48\x2A' | |
with open(os.path.abspath(eicar_file), 'wb') as file: | |
file.write(eicar_string) |
This file contains 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
options { | |
use_dns(yes); | |
owner("log"); | |
group("log"); | |
create_dirs(yes); | |
perm(0750); | |
dir_perm(0750); | |
dir_owner("log"); | |
dir_group("log"); | |
}; |