Skip to content

Instantly share code, notes, and snippets.

View itdaniher's full-sized avatar

itdaniher itdaniher

  • mosslandia
View GitHub Profile
@itdaniher
itdaniher / tiny_dhcp.py
Created April 4, 2018 20:40
tiny_dhcp.py
from threading import Thread
from scapy.layers.inet import Ether, IP, UDP
from scapy.layers.dhcp import DHCP, BOOTP
from scapy.config import conf
from scapy.arch import get_if_raw_hwaddr, get_if_hwaddr
from scapy.sendrecv import sniff, sendp
import queue
import time
BOOTREPLY = 2
def dhcp_reqresp(interface="wwan0", timeout=5):
@itdaniher
itdaniher / tiny_dns.py
Created April 4, 2018 00:05
tiny_dns.py
import os
import socket
import struct
import asyncio
import logging
DNS_SERVER = '8.8.8.8'
DNS_PORT = 53
@itdaniher
itdaniher / dev.yml
Created March 28, 2018 15:40
ansible build script for basic development environment
- hosts: all
remote_user: root
tasks:
- user: name=name state=present shell=/bin/bash
- name: setup resolv.conf
lineinfile: path=/run/resolvconf/resolv.conf line='nameserver 8.8.8.8' create=yes state=present
- name: hardcode ports.ubuntu.com
lineinfile: path=/etc/hosts line='91.189.88.150 ports.ubuntu.com' state=present
- name: aptitude
apt: name=aptitude state=installed
@itdaniher
itdaniher / sim7100a dmesg
Last active March 16, 2018 01:30
sim7100a dmesg
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Linux version 3.0.21+ (benxiwang@benxiwang-Lenovo) (gcc version 4.6.3 20111117 (prerelease) (GCC) ) #1 PREEMPT Mon Oct 10 12:53:23 CST 2016
[ 0.000000] CPU: ARMv7 Processor [410fc051] revision 1 (ARMv7), cr=10c5387d
[ 0.000000] CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
[ 0.000000] Machine: QCT MSM9615 CDP
[ 0.000000] Partition (from atag) boot -- Offset:2fc Size:52
[ 0.000000] Partition (from atag) sbl2 -- Offset:a Size:1b
[ 0.000000] Partition (from atag) rpm -- Offset:25 Size:1b
[ 0.000000] Partition (from atag) efs2 -- Offset:40 Size:53
[ 0.000000] Partition (from atag) dsp1 -- Offset:93 Size:1f
@itdaniher
itdaniher / null
Created March 16, 2018 00:47
got root
PID USER TIME COMMAND
1 root 0:01 init [5]
2 root 0:00 [kthreadd]
3 root 0:00 [ksoftirqd/0]
4 root 0:00 [kworker/0:0]
5 root 0:00 [kworker/u:0]
6 root 0:00 [khelper]
7 root 0:00 [netns]
8 root 0:00 [sync_supers]
9 root 0:00 [bdi-default]
@itdaniher
itdaniher / start_redis.py
Created February 1, 2018 21:50
spawn a memcached-like redis instance
def start_redis_server(redis_socket_path = "/tmp/redis.sock"):
conf = b"""port 0
databases 1
unixsocket %s
maxmemory 100mb
maxmemory-policy volatile-lru
save ''""" % redis_socket_path.encode()
logging.debug('launching redis with conf: %s' % conf)
redis_process = subprocess.Popen(['redis-server', "-"], stdin = subprocess.PIPE, start_new_session=True)
try:
@itdaniher
itdaniher / pastebin.py
Created January 30, 2018 02:56
a dumb poc - worked better when py2.7 was a thing
import sys
import os
from urllib.request import urlopen
from urllib.parse import urlencode
from time import time
from copy import copy
from re import findall
PASTEBIN_URL = 'https://pastebin.com/api/api_post.php'
PASTEBIN_LOGIN_URL = 'https://pastebin.com/api/api_login.php'
@itdaniher
itdaniher / dns.py
Created January 23, 2018 19:03 — forked from infra-0-0/dns.py
python3.5 asyncio dns resolver, based on code from who knows where
import os
import socket
import struct
import asyncio
import logging
DNS_SERVER = '8.8.8.8'
DNS_PORT = 53
def encode_header(packet_id):
@itdaniher
itdaniher / test.py
Created January 23, 2018 15:26
functools.lru caches fds
import os
import sys
import traceback
import pyroute2.netns
i = 0
import functools
@functools.lru_cache(maxsize=1024)
def get_fd_from_netnspath(netnspath):
@itdaniher
itdaniher / test.py
Created January 22, 2018 16:35
setns leaks FDs
import sys
import traceback
import pyroute2.netns
i = 0
while True:
try:
pyroute2.netns.setns('/proc/1/ns/net')
except:
traceback.print_exc(file=sys.stderr)
print(i)