Skip to content

Instantly share code, notes, and snippets.

import logging
import logging.handlers
import argparse
import socket
def arguments():
parser = argparse.ArgumentParser(__file__, description='syslog logger')
parser.add_argument("--address", "-n", default="localhost")
from __future__ import print_function
import json
import sys
import pprint
import argparse
import cStringIO
import tarfile
parser = argparse.ArgumentParser()
parser.add_argument("-g", "--grep")
import sys
import datetime
import json
import argparse
import logging
try:
from elasticsearch import Elasticsearch
except ImportError:
print("Please install elasticsearch-py first")
sys.exit(1)
@haginara
haginara / LookupAccountNameA.py
Last active February 25, 2016 19:20
LookupAccountNameA function using ctypes
# coding: utf-8
import ctypes
from ctypes.wintypes import *
LPVOID = ctypes.c_void_p
PVOID = LPVOID
PSID = PVOID
LPDWORD = ctypes.POINTER(DWORD)
@haginara
haginara / inject_pycode.py
Last active April 16, 2021 15:54
inject python code into running process
# coding: utf-8
from winappdbg import Process, System
import sys
import time
import ctypes.util
if __name__ == '__main__':
python_lib = "python{0}{1}.dll".format(sys.version_info.major, sys.version_info.minor)
python_dll = ctypes.util.find_library(python_lib)
s = System()
@haginara
haginara / es-index.py
Last active March 2, 2016 19:56
Managing elasticsaerch index using python
import sys
import datetime
import json
import copy
import argparse
import logging
try:
from elasticsearch import Elasticsearch
except ImportError:
print("Please install elasticsearch-py first")
@haginara
haginara / model_to_dict.py
Last active March 28, 2024 15:35
Custom model_to_dict.py that supports ManyToOne Fields
from itertools import chain
def model_to_dict(instance, fields=None, exclude=None):
"""
Returns a dict containing the data in ``instance`` suitable for passing as
a Form's ``initial`` keyword argument.
``fields`` is an optional list of field names. If provided, only the named
fields will be included in the returned dict.
import requests
import sys
import json
import os
def out(text, *args):
print(text % args)
HOST = "http://127.0.0.1:9200"
QUERY = "_nodes/stats"
NODE = 'data'
#!/usr/bin/env python
import sys
import datetime
import json
import argparse
import logging
from collections import namedtuple
try:
from elasticsearch import Elasticsearch
@haginara
haginara / windows_update.py
Created August 29, 2018 01:04
Windows Update Scripts
import argparse
import win32com
import win32com.client
import os
import re
try:
import _winreg as winreg
except ImportError:
import winreg