Skip to content

Instantly share code, notes, and snippets.

@Manouchehri
Manouchehri / cloudflare.sh
Last active May 21, 2025 14:03
Allow CloudFlare only
# Source:
# https://www.cloudflare.com/ips
# https://support.cloudflare.com/hc/en-us/articles/200169166-How-do-I-whitelist-CloudFlare-s-IP-addresses-in-iptables-
for i in `curl https://www.cloudflare.com/ips-v4`; do iptables -I INPUT -p tcp -m multiport --dports http,https -s $i -j ACCEPT; done
for i in `curl https://www.cloudflare.com/ips-v6`; do ip6tables -I INPUT -p tcp -m multiport --dports http,https -s $i -j ACCEPT; done
# Avoid racking up billing/attacks
# WARNING: If you get attacked and CloudFlare drops you, your site(s) will be unreachable.
iptables -A INPUT -p tcp -m multiport --dports http,https -j DROP
@Manouchehri
Manouchehri / lockdown.sh
Last active August 29, 2015 14:23
Secure SSH
# wget -O - https://gist***/lockdown.sh | bash
# Lock down SSH
sshport=$(shuf -i 49152-65000 -n1) &&
sed -i "s/Port 22/Port $sshport/; s/PermitRootLogin yes/PermitRootLogin no/; s/#PasswordAuthentication yes/PasswordAuthentication no/" /etc/ssh/sshd_config &&
# Get wordlist
apt-get update &&
apt-get install -y wamerican &&
@Manouchehri
Manouchehri / logmein.txt
Created June 24, 2015 22:35
Support-LogMeInRescue.exe wine error (invalid certs)
GET /myrahost/list.aspx?weighed=1 HTTP/1.0
Host: secure.logmeinrescue.com
Pragma: no-cache
Connection: Keep-Alive
User-Agent: Product=LogMeIn Rescue;Component=IC Applet;Version=7.6.403.1728;LMIOS=16844544;
Content-Length: 0
sudo tar -cvpf - --one-file-system / --exclude=/swapfile | lz4 - /mnt/[put drive here]/system.backup.tar.lz4
@Manouchehri
Manouchehri / iperf-openvpn.txt
Created July 25, 2015 22:00
iperf benchmark across a OpenVPN network.
~ > iperf -u -c 10.8.0.14 -t60 -P32
------------------------------------------------------------
Client connecting to 10.8.0.14, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size: 208 KByte (default)
------------------------------------------------------------
[ 34] local 10.8.0.6 port 44930 connected with 10.8.0.14 port 5001
[ 4] local 10.8.0.6 port 53085 connected with 10.8.0.14 port 5001
[ 5] local 10.8.0.6 port 41582 connected with 10.8.0.14 port 5001
[ 3] local 10.8.0.6 port 50268 connected with 10.8.0.14 port 5001
@Manouchehri
Manouchehri / iperf-local.txt
Created July 25, 2015 22:09
iperf benchmark across a local network
~ > iperf -c 192.168.1.138 -t60 -P32
------------------------------------------------------------
Client connecting to 192.168.1.138, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[ 24] local 192.168.1.175 port 40313 connected with 192.168.1.138 port 5001
[ 5] local 192.168.1.175 port 40292 connected with 192.168.1.138 port 5001
[ 4] local 192.168.1.175 port 40291 connected with 192.168.1.138 port 5001
[ 3] local 192.168.1.175 port 40290 connected with 192.168.1.138 port 5001
[ 7] local 192.168.1.175 port 40293 connected with 192.168.1.138 port 5001
~ > ping -fi0.2 192.168.1.1 -c1000
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
--- 192.168.1.1 ping statistics ---
1000 packets transmitted, 1000 received, 0% packet loss, time 200398ms
rtt min/avg/max/mdev = 0.883/1.457/70.247/2.956 ms, ipg/ewma 200.599/1.183 ms
~ > ping -fi0.2 192.168.1.138 -c300
PING 192.168.1.138 (192.168.1.138) 56(84) bytes of data.
@Manouchehri
Manouchehri / windows10qemu.sh
Last active February 10, 2022 18:50
Running Windows 10 in a UEFI enabled QEMU environment with KVM.
# Installing
qemu-system-x86_64 -bios /usr/share/ovmf/ovmf_x64.bin -enable-kvm -cpu host -smp 4 -m 2048 -cdrom ~/Downloads/Win10_English_x64.iso -net nic,model=virtio -net user -drive file=~/vm/win10.hd.img.raw,format=raw,if=virtio -vga qxl -drive file=~/Downloads/virtio-win-0.1.105.iso,index=1,media=cdrom
# Running
qemu-system-x86_64 -bios /usr/share/ovmf/ovmf_x64.bin -enable-kvm -cpu host -smp 4 -m 4096 -net nic,model=virtio -net user -drive file=~/vm/win10.hd.img.raw,format=raw,if=virtio -vga qxl -usbdevice tablet -rtc base=utc
@Manouchehri
Manouchehri / iperf-openvpn-compression.txt
Created August 1, 2015 23:20
A quick example showing how OpenVPN's compression can skew the results of a benchmark.
~ > iperf -u -c 10.8.0.14 -t600 -b 31M
------------------------------------------------------------
Client connecting to 10.8.0.14, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size: 208 KByte (default)
------------------------------------------------------------
[ 3] local 10.8.0.6 port 59585 connected with 10.8.0.14 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-600.0 sec 2.17 GBytes 31.0 Mbits/sec
[ 3] Sent 1583073 datagrams
@Manouchehri
Manouchehri / find_nonexistence_packages.sh
Created August 26, 2015 17:33
Short one-liner to identify locally installed packages from the AUR3 that haven't been migrated to the AUR4 yet.
#!/bin/bash
for x in `yaourt -Qmq`; do yaourt -Si "$x" || echo "$x" >> missing.txt; done