Skip to content

Instantly share code, notes, and snippets.

@hijak
hijak / Windows-Interfaces
Last active December 27, 2015 02:09
Windows Powershell examples for interface config
##rename interface
netsh interface set interface name=”Old Name” newname=”newname”
##add ip config
netsh interface ip set address name="Public" static 192.168.0.100 255.255.255.0 192.168.0.1
##add dns config
netsh interface ip add dns "public" 83.138.151.80 INDEX=1
netsh interface ip add dns "public" 83.138.151.81 INDEX=2
@hijak
hijak / ESX-5.1-QC
Last active December 27, 2015 02:09
ESXi 5.1 QC commands
###Displays current hostname
hostname
###shows order or nics should display I350 gigbit nics as first as these are the onboard ports (r720)
esxcfg-nics -l
###Shows IP addresses for management interfaces and vMotion
esxcfg-vmknic -l | grep IPv4
###ExNet management gateway (public gateway)
@hijak
hijak / Eth-Remap-rhel-deb
Created October 31, 2013 14:34
Ethernet Nic Name Remapping
###For RedHat distros
lspci -vv | grep 'Ethernet\|Serial' | awk 'NR == 1{ printf $1 } NR == 2 { print " mac " $7 }' | sed –e 's/-/:/g' -e 's/:f[ef]:f[ef]//g' -e 's/01:00.0/eth0/g' -e 's/01:00.1/eth1/g' -e 's/01:00.2/eth2/g' -e 's/01:00.3/eth3/g' > /etc/iftab && ifrename
###For Debian distros
lspci -vv | grep 'Ethernet\|Serial' | awk 'NR == 1{ printf $1 } NR == 2 { print $7 }' | sed –e 's/-/:/g' -e 's/:f[ef]:f[ef]//g' -e 's/01:00.0/eth0/g' -e 's/01:00.1/eth1/g' -e 's/01:00.2/eth2/g' -e 's/01:00.3/eth3/g' > /etc/mactab && nameif
@hijak
hijak / nginX-useful
Created November 1, 2013 09:18
Nginx Useful location entry's
###only allow GET and HEAD requests (if request method IS NOT get or head then return 405 error)
if ($request_method !~ ^(GET|HEAD)$ ) {
return 405;
}
###deny other host headers (ref scams) (if the host is not mydomain return 405 error)
if ($host !~* ^(mydomain.com|www.mydomain.com)$ ) {
return 405;
}
@hijak
hijak / qc.sh
Created January 4, 2014 20:32
QC SCRIPT
#!/bin/bash
#a QC script helper
read -p "
----------------------------------------------------------------
QC SCRIPT HELPER Press enter to continue Press ctrl-c to exit
----------------------------------------------------------------" &&
@hijak
hijak / lighttpd
Created October 28, 2014 10:55
lighttpd bad bot blocker
$HTTP["useragent"] =~ "(|Aboundex|80legs|360Spider|^Java|^Cogentbot|^Alexibot|^asterias|^attach|^BackDoorBot|^BackWeb|Bandit|^BatchFTP|^Bigfoot|^Black.Hole|^BlackWidow|^BlowFish|^BotALot|Buddy|^BuiltBotTough|^Bullseye|^BunnySlippers|^Cegbfeieh|^CheeseBot|^CherryPicker|^ChinaClaw|Collector|Copier|^CopyRightCheck|^cosmos|^Crescent|^Custo|^AIBOT|^DISCo|^DIIbot|^DittoSpyder|^Download\ Demon|^Download\ Devil|^Download\ Wonder|^dragonfly|^Drip|^eCatch|^EasyDL|^ebingbong|^EirGrabber|^EmailCollector|^EmailSiphon|^EmailWolf|^EroCrawler|^Exabot|^Express\ WebPictures|Extractor|^EyeNetIE|^Foobot|^flunky|^FrontPage|^Go-Ahead-Got-It|^gotit|^GrabNet|^Grafula|^Harvest|^hloader|^HMView|^HTTrack|^humanlinks|^IlseBot|^Image\ Stripper|^Image\ Sucker|Indy\ Library|^InfoNaviRobot|^InfoTekies|^Intelliseek|^InterGET|^Internet\ Ninja|^Iria|^Jakarta|^JennyBot|^JetCar|^JOC|^JustView|^Jyxobot|^Kenjin.Spider|^Keyword.Density|^larbin|^LexiBot|^lftp|^libWeb/clsHTTP|^likse|^LinkextractorPro|^LinkScan/8.1a.Unix|^LNSpiderguy|^LinkWalker|^lwp-
@hijak
hijak / gist:1bfa60b7d7516cba1dfb
Last active August 29, 2015 14:11
SSH brute detect
failed attempts
awk '/Failed password/ {print $(NF-3)}' /var/log/secure |sort -n|uniq -c|sort -nk1|awk '{sum+=$1;if($1>300)print "IP: ",$2,"Failed login",$1,"Times"}END{print "\nTotal failed attempts:\t"sum}'
or
cat /var/log/secure | grep sshd | grep Failed | sed 's/invalid//' | sed 's/user//' | awk '{print $11}' | sort | uniq -c | sort -rn
or
grep "Failed password for" /var/log/secure | grep "Dec  8" | awk '{print $11}' | sort | uniq -c | sort -nr | head -7
connections to ssh
netstat -antp|awk '{gsub(/[f:]/, " ");if($7 ~ /22/)print "LOCAL: ",$6,"TARGET: ",$4,"STATE: ",$8}'|sort|uniq -c|sort -nk1|awk '{sum += $1;print}END{print "Total:\t"sum}'
print ip of eth0
ip a s eth0 | sed -nr 's!.*inet ([^/]+)/.*!\1!p'
print groups
cut -d: -f1 /etc/group | sort
find external ip address
curl http://canihazip.com/s && echo
load of server/mem/disk
@hijak
hijak / zzz_disablev3.conf
Created December 11, 2014 08:22
disable sslv3
<IfModule mod_ssl.c>
SSLProtocol All -SSLv2 -SSLv3
SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:!LOW:!SSLv2:!EXP
</IfModule>
@hijak
hijak / eztv
Last active August 29, 2015 14:18
eztv rproxy
var startingPort = 2011
var neoProxy = require('neo-proxy')
var customHTML = '<center><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-9374665233285997" data-ad-slot="9625600444"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></center></br>'
var batman = neoProxy({
port: startingPort,
target: 'https://eztv.ch',
needle: '<div id="line"></div>',