Skip to content

Instantly share code, notes, and snippets.

View mostafahussein's full-sized avatar
💀
K3rn3l Cr4sh3r

(╯°□°)╯︵ uᴉǝssnH ɐɟɐʇsoW mostafahussein

💀
K3rn3l Cr4sh3r
View GitHub Profile
@mostafahussein
mostafahussein / sar_to_json.py
Created April 12, 2017 10:02 — forked from beugley/sar_to_json.py
Python: convert sar (sadf) to json format
#!/usr/bin/env python
###############################################################################
## sar_to_json.py
##
## Reformats output from sadf to json. sadf must be invoked with the -D
## switch. Timestamps are displayed in ISO6801 format (YYYY-MM-DDThh:mm:ssZ).
## Example: sadf -D -- -A | sar_to_json.py
###############################################################################
import sys
@mostafahussein
mostafahussein / BotLovin.cs
Created March 11, 2017 17:53 — forked from NickCraver/BotLovin.cs
Some bot/crawler fun on Stack Overflow. 10 hours of fun, to be precise.
private static readonly string[] tenHoursOfFun =
{
"https://www.youtube.com/watch?v=wbby9coDRCk",
"https://www.youtube.com/watch?v=nb2evY0kmpQ",
"https://www.youtube.com/watch?v=eh7lp9umG2I",
"https://www.youtube.com/watch?v=z9Uz1icjwrM",
"https://www.youtube.com/watch?v=Sagg08DrO5U",
"https://www.youtube.com/watch?v=ER97mPHhgtM",
"https://www.youtube.com/watch?v=jI-kpVh6e1U",
"https://www.youtube.com/watch?v=jScuYd3_xdQ",
Use TCPDUMP to Monitor HTTP Traffic
1. To monitor HTTP traffic including request and response headers and message body:
tcpdump -A -s 0 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
2. To monitor HTTP traffic including request and response headers and message body from a particular source:
tcpdump -A -s 0 'src example.com and tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
3. To monitor HTTP traffic including request and response headers and message body from local host to local host:
@mostafahussein
mostafahussein / gist:03b4633a3d6512c0c0a3479062bef14f
Created January 14, 2017 14:36 — forked from antics/gist:4079584
Login to Wordpress with curl
curl -D cookie1.txt blog.xrmplatform.org/wp-login.php
# step 1
# get default cookie of blog and write cookie to cookie1.txt
# step 2
# simulate browser Firefox( of course , you can use any browser agent<!--more--> what you want!) "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"
# input your username and also password
# write new cookie to cookie2.txt
curl -A "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6" -D cookie2.txt -b cookie1.txt -F log=username -F pwd=password -F testcookie=1 -F wp-submit="Log In" -F redirect_to=blog.xrmplatform.org/wp-admin -F submit=login -F rememberme=forever blog.xrmplatform.org/wp-login.php
# currently cookie2.txt stored all cookie info
@mostafahussein
mostafahussein / sum.js
Last active January 4, 2017 13:24
Add two numbers using bitwise operators https://jsfiddle.net/deadshot/ugycbacd/
// Based on the following answer : http://codegolf.stackexchange.com/questions/20996/add-without-addition-or-any-of-the-4-basic-arithmetic-operators/21025#21025
var x = 6;
var y = 6;
var result = function () {
var sum = 0
while (y) {
sum = x^=y,y=(y&x^y)<<1
}
return sum
};
git clone https://github.com/Lurk/ffmpeg-php > /dev/null 2>&1 ; cd ffmpeg-php ; ./configure && make && make install
@mostafahussein
mostafahussein / Selenium PhantomJS Python Header.py
Created November 19, 2016 12:41 — forked from ozen/Selenium PhantomJS Python Header.py
How to set request headers when using Selenium Python with PhantomJS driver
from selenium import webdriver
from selenium.webdriver import DesiredCapabilities
desired_capabilities = DesiredCapabilities.PHANTOMJS.copy()
desired_capabilities['phantomjs.page.customHeaders.User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) ' \
'AppleWebKit/537.36 (KHTML, like Gecko) ' \
'Chrome/39.0.2171.95 Safari/537.36'
driver = webdriver.PhantomJS(desired_capabilities=desired_capabilities)
import subprocess
import re
regex = re.compile('([A-Z]+)=(?:"(.*?)")')
parts = "NAME,KNAME,MODEL,UUID,SIZE,ROTA,TYPE,MOUNTPOINT,MAJ:MIN"
def blocks():
blocks = []
output = subprocess.check_output([
"sudo", "lsblk", "-P", "-o",
@mostafahussein
mostafahussein / install.md
Created October 26, 2016 01:44 — forked from johnantoni/install.md
install duplicity on centos 64bit

check os

cat /etc/redhat-release

install repo

sudo rpm -Uvh http://mirrors.kernel.org/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
yum repolist

install duplicity

@mostafahussein
mostafahussein / check_salt
Created October 17, 2016 03:08 — forked from bastichelaar/check_salt
Nagios script to check whether a salt minion is online (with timeout)
#!/usr/bin/env python
import salt.cli.caller
import salt.config
import argparse
import sys
import signal
class TimeoutException(Exception):
pass