Skip to content

Instantly share code, notes, and snippets.

View rohan-molloy's full-sized avatar

Rohan rohan-molloy

View GitHub Profile
@rohan-molloy
rohan-molloy / isp-bgp-prefix.md
Last active May 30, 2019 15:08
One Liner To Get ISP announced prefix

One Liner To Get ISP announced prefix info

dig +short `curl --silent ipecho.net/plain | awk -F. '{print $4"."$3"." $2"."$1}'`.origin.asn.cymru.com TXT

Example

rohan@vm01:~$ dig +short `curl --silent ipecho.net/plain | awk -F. '{print $4"."$3"." $2"."$1}'`.origin.asn.cymru.com TXT
"46652 | 67.205.128.0/20 | US | arin | 2016-04-12"
rohan@vm01:~$
#!/bin/sh
RESPONSE=`curl -s -X GET http://hi.link/api/webserver/SesTokInfo`
COOKIE=`echo "$RESPONSE"| grep SessionID=| cut -b 10-147`
TOKEN=`echo "$RESPONSE"| grep TokInfo| cut -b 10-41`
DATA="<request><PageIndex>1</PageIndex><ReadCount>3</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>1</UnreadPreferred></request>"
curl -b $COOKIE -c $COOKIE -H "X-Requested-With: XMLHttpRequest" --data "$DATA" http://hi.link/api/sms/sms-list --header "__RequestVerificationToken: $TOKEN" --header "Content-Type:text/xml"
@rohan-molloy
rohan-molloy / dns.md
Last active June 18, 2017 18:09
Forcing all vpn clients to use a particular dns

Hijacking dns traffic with iptables nat

We put this on the vpn server (which functions much like a home router, doing NAT and dns resolving)

  iptables -t nat -A PREROUTING -i tun0 -p udp -m udp --dport 53 ! -d 10.53.1.53 -j DNAT --to-destination 10.53.1.53
  iptables -t nat -A PREROUTING -i tun0 -p tcp -m tcp --dport 53 ! -d 10.53.1.53 -j DNAT --to-destination 10.53.1.53

So for connections entering via tun0 (the internal side), that leave to an external destination on the DNS,

we redirect them to our dns server (10.53.1.53), although we could pick an external server if we wanted to.

3.141592653589793238462643383279
5028841971693993751058209749445923
07816406286208998628034825342117067
9821 48086 5132
823 06647 09384
46 09550 58223
17 25359 4081
2848 1117
4502 8410
2701 9385
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_rfc1337 = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.accept_redirects=0
net.ipv4.conf.all.accept_redirects=0
net.ipv6.conf.default.accept_redirects=0

Rsyslog.conf

provides support for local system logging

$ModLoad imuxsock 

provides kernel logging support

$ModLoad imklog   
`-:+ossyyyysso+:-`
./osssssssssssssssssyo/.
:osssssssssssssssssssssssso:
-osssssssssssssssssssssssssssss:
+ssssssssssssso++++ossssssssssssso`
`osssssssssso:. .:osssssssssss`
+ssssssssso- `````` .ossssssssso
-sssssssss+ `........` /sssssssss:
+sssssssss `...........` osssssssss
server.socket = "0.0.0.0:443"
server.username = "www-data"
server.groupname = "www-data"
server.modules = (
"mod_proxy",
"mod_access",
"mod_compress",
)
ssl.dh-file = "/etc/lighttpd/dh2048.pem"
ssl.ec-curve = "secp384r1"
alias Escape-HTML="sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g'; s/' '/&nbsp;/ | sed ':begin;$!N;s/\n/<br \/>/;tbegin'"
awk {'print "local-data: \""$2" IN A "$1"\nlocal-data ptr: \""$1" "$2"\""}' <(grep -v ^# /etc/hosts | grep -v localhost) | grep -v 'local-data: " IN A ' | grep -v 'local-data ptr: " "
'