Skip to content

Instantly share code, notes, and snippets.

View Mithrilwoodrat's full-sized avatar
🎯
Focusing

xiaoxianyu Mithrilwoodrat

🎯
Focusing
View GitHub Profile
@Mithrilwoodrat
Mithrilwoodrat / resources.md
Created October 13, 2020 09:20 — forked from fffaraz/resources.md
CS 306 - Linux/UNIX Programming
@Mithrilwoodrat
Mithrilwoodrat / netstat.py
Created February 26, 2019 15:50
Linux netstat in python
# -*- coding: utf-8 -*-
# ref
# * https://gist.github.com/aleiphoenix/0e886336522c2f41412d
# * https://stackoverflow.com/questions/3319521/how-can-i-match-each-proc-net-tcp-entry-to-each-opened-socket
# * https://stackoverflow.com/questions/14667215/finding-a-process-id-given-a-socket-and-inode-in-python-3
# read /proc/net/tcp get address port and inode. get pid by checking every sysbol link to this inode in every /proc/<PID>/fd
import re
import os
import sys
@Mithrilwoodrat
Mithrilwoodrat / install.txt
Created December 2, 2018 03:47 — forked from xiaol825/install.txt
How to install Chrome, ChromeDriver and Selenium on CentOS. Plus a sample scraping script.
#!/usr/bin/env bash
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/
# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c
# http://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver
# http://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception
# http://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal
# http://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04
# Versions
CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`
  1. Install Notepad++ (check "set as default HTML editor" to replace Notepad in IE).
  2. Run Notepad++, update its plugins, and install "NppExec" via Plugins, Plugin Manager.
  3. Enter these scripts for Python debugging:

Press F6 to create a NppExec Execute script, save as "Run Python":

cd "$(CURRENT_DIRECTORY)"
py.exe "$(FILE_NAME)"
@Mithrilwoodrat
Mithrilwoodrat / Scapy_TcpSession.py
Created August 26, 2018 11:56 — forked from N0dr4x/Scapy_TcpSession.py
Simple Scapy TCP Session
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Author: N0dr4x (n0dr4x@protonmail.com)
'''
Simple Scapy TCP Session class that provide ability
to :
- execute the 3-way handshake (eg. connect)
- properly close connection (->FIN/ACK, <-FIN/ACK, ->ACK )
- send automatic acknowledgment of received tcp data packet
@Mithrilwoodrat
Mithrilwoodrat / WSL-ssh-server.md
Created June 22, 2018 14:44 — forked from dentechy/WSL-ssh-server.md
A step by step tutorial on how to automatically start ssh server on boot on the Windows Subsystem for Linux

How to automatically start ssh server on boot on Windows Subsystem for Linux

Microsoft partnered with Canonical to create Bash on Ubuntu on Windows, running through a technology called the Windows Subsystem for Linux. Below are instructions on how to set up the ssh server to run automatically at boot.

  1. Uninstall and reinstall the ssh server using the following commands:
    1. sudo apt remove openssh-server
    2. sudo apt install openssh-server
  2. Edit the /etc/ssh/sshd_config file by running the command sudo vi /etc/ssh/sshd_config and do the following
    1. Change Port to 2222 (or any other port above 1000)
  3. Change UsePrivilegeSeparation to no
@Mithrilwoodrat
Mithrilwoodrat / snort.strace
Created May 19, 2018 11:07
snort.strace in WSL kali
20968 execve("/usr/sbin/snort", ["snort", "-ilo"], 0x7fffdb9b5900 /* 15 vars */) = 0
20968 brk(NULL) = 0x1c0e000
20968 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20968 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
20968 openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
20968 fstat(3, {st_mode=S_IFREG|0644, st_size=35094, ...}) = 0
20968 mmap(NULL, 35094, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f848ac5c000
20968 close(3) = 0
20968 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20968 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libdumbnet.so.1", O_RDONLY|O_CLOEXEC) = 3
@Mithrilwoodrat
Mithrilwoodrat / install-pypy.sh
Created October 26, 2016 06:59 — forked from baoshan/install-pypy.sh
Install PyPy on CentOS
# yum list \*openssl\*
yum install -y openssl098e
yum install -y zlib
ln -s /usr/lib64/libssl.so.0.9.8e /usr/lib64/libssl.so.0.9.8
ln -s /usr/lib64/libcrypto.so.0.9.8e /usr/lib64/libcrypto.so.0.9.8
ln -s /lib64/libbz2.so.1 /lib64/libbz2.so.1.0
wget https://bitbucket.org/pypy/pypy/downloads/pypy-1.8-linux64.tar.bz2
tar -xf pypy-1.8-linux64.tar.bz2
cp -r pypy-1.8 /opt
ln -s /opt/pypy-1.8/bin/pypy /usr/local/bin
def find(key, dictionary):
for k, v in dictionary.iteritems():
if k == key:
yield v
elif isinstance(v, dict):
for result in find(key, v):
yield result
elif isinstance(v, list):
for d in v:
for result in find(key, d):
@Mithrilwoodrat
Mithrilwoodrat / es.py
Last active March 26, 2018 09:22
python script to make curl cmd for request elasticsearch
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
## usage: chmod +x es.py & mv es.py /usr/bin/es
## edit file to custom server
import os
from optparse import OptionParser
from urllib2 import urlparse
SERVER = "http://127.0.0.1:9200/"
METHODS = ["GET", "PUT", "POST", "DELETE"]