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 functools | |
def st_cache_monitor(func): | |
""" A decorator to handle query_cache=hit/miss utility """ | |
@functools.wraps(func) | |
def wrapper_func(*args, _querying_cache=None, **kwargs): | |
""" Wrapper to original func to handle special argument _querying_cache """ | |
if _querying_cache is Ellipsis: | |
raise LookupError("_querying_cache=`miss`") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#!python3 | |
#script to delete all files OLDER than minAge_sec inside basepath (recursively) | |
#set these args before running | |
basepath="." | |
minAge_sec=14*24*60*60 #14days | |
logfilepath="~/deletionJob.log" | |
#ofcourse, logfilepath should lie outside basepath | |
import os,time |
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
#batch find replace | |
basepath=input("Enter fullpath of project rootdir:") | |
findtext=input("Enter fullpath of find_to text file:") | |
reptext=input("Enter fullpath of replace_with text file:") | |
endswithfilter=input("Enter the string the target files should end with [.html for example]:") | |
#setting | |
progress=1000#report after every n no. of files. | |
encoding='latin-1'#encoding to read and write all files with |
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
def burp2req(rawDump): | |
"""paste the raw dump from burp suite and replace all variables b/w << >>. | |
It will return an equivalent py function that accepts variables from dump and returns response obj""" | |
head=list(map(str.strip,rawDump.split("\n\n",1))) | |
if len(head)==2:head,body=head | |
else:head,body=head[0]," " | |
l1,head=head.split('\n',1) | |
l1,head=l1.split(),dict([map(str.strip,h.split(":",1)) for h in head.split('\n') if h.strip()]) | |
host=head.get('Host',head.get('host',head.get("HOST",None))) | |
pr="https://" if l1[-1]=="HTTP/1.1" else "http://" |
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
def py2ipy(fpy): | |
import nbformat | |
import re | |
from nbformat.v4 import new_notebook, new_code_cell | |
with open(fpy) as f: | |
src = f.read() | |
src = src.replace('# coding: utf-8', '') | |
cells = [new_code_cell(cell) for cell in re.split('\n\n\n# In\[[0-9]+\]:\n\n\n', src)] |
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
malCfile="maliciousOnly.txt" | |
baseDir="back_up_dir/websites" | |
replCfile="disInfectedComment.txt" | |
workext="js,php" | |
import sys,os,time,json | |
if sys.version_info[0] < 3: | |
input=raw_input | |
print("Current Directory:") | |
print(os.path.abspath(os.getcwd())) |
NewerOlder