Posts

Again Diamond ..

c=25; for i in {1..25}; do temp=$c; while [ $temp -gt 0 ]; do printf " "; temp=$(( temp - 1 )); done; j=$i; if [ $j -eq 1 ]; then printf "*"; else v=$(( j * 2 )); while [ $v -gt 0 ]; do printf "*"; v=$(( v - 1 )); done; fi; c=$(( c - 1 )); printf "\n"; done; v=1;a=25; while [ $a -gt 0 ]; do j=$(( 25 - a )); while [ $j -ge 0 ]; do printf " "; j=$(( j - 1 )); done; t=$(( a * 2 )); while [ $t -gt 0 ] ; do printf "*"; t=$(( t - 1)); done; a=$(( a - 1 )); if [ $a -eq -1 ] ; then printf "*"; fi; printf "\n"; done;

ip_classifier.py for ipv32

Written simple program to find the class for an ip address of 32bit version #!/usr/bin/python import sys, getopt def __help(): sys.stderr.write('\n Usage: \n ip_classifier.py -h \n ip_classifier.py --help \n ip_classifier.py -i 128.12.14.23 \n ip_classifier.py --ipv4=128.12.14.23 \n ') sys.exit() def __input_validator(check): if len(check) 0: check = list(check) c = 0; n = 0 for v in check: if v in ['.','1','2','3','4','5','6','7','8','9','0']: n += 1 test = True if v is '.': c += 1 else: test = False break if test and c 6: return check else: sys.stderr.write('**** Enter correct ip address **** \n') __help() def __validator(ip): if ip in range(0,256): return True else: sys.stderr.write('**** Enter correct ip address **** \n') __help() def __class_finder(ip, class_ip, bin_ip): i='' dict ...

OSI Layer

Image

Subnetting Basics - Self Learn

Image
To understand IP address resolution, you need to understand how to decode the IP address and extract the two main identifiers: A network ID (the network bits) A host ID (the bits the system administrator controls locally when assigning IP addresses) Network ID is used to identify the number of  networks and Host ID is used to identify the number of hosts on the local-area network. For now, just keep in mind a few subnetting basics: A  subnet  mask — or  subnet  address — is used by routers to assist in determining the network portion of an IP address from the host portion. The  subnet  mask is a 32-bit value just like the IP address. The binary 1 bits correspond to the network and  subnet  portions of the address. The 0 bits are host representatives. Three standard masks exist for Class A, B, and C networks: Standard Class A   subnet  mask: 255.0.0.0 Standard Class B   subnet  mask...

Network Addressing IPv4 - Self Learn

Image
Network Addressing: Each device on a TCP/IP (IPv4) network uses a unique 4-byte, or 32-bit, decimal IP address for communication and is composed of two distinct parts: a  network address  and a  host address. Each 8 byte is called octet. Example: 172.168.16.100 172 -> belongs class B 172.168. is the network address 16.100 is the host address Routing is done based on the network address. Each octet can have the value between 0-255. Classes of IP Addresses Two of the main ones are designated for the  default route  and  loopback address. The default route address is represented as 0.0.0.0 and is used to simplify the routing information that IP uses. Any route lookup failure defaults back to this route. The loopback address space is 127.0.0.0 and is used for testing and treating a local host as if it were remote to the network.  Class A (0–127): '0'  Class B (128–191):   '10' Class C (192...

Networking Basics - Self Study

Image
A common connection point for the devices  like computer, smartphones in the network  are due to the hubs, switches, repeaters and routers. Networking Components: Hub has multiple ports. When the frame arrives at one port, it broadcast the same message to all other ports. Hub does not check the destination address, it simply broadcast to all available ports. Hubs are less intelligent as it works on physical layer (L1) of OSI model it does not know the MAC address of the ports connected to the network. It lacks in security, so the attacker can sniff the neighbor packets. (Hubs are outdated) Hub can create lot of network traffic and lead to poor response times. Repeater is also similar to hub, but it is used to amplifies the input the signal. When input signal has both desired signal and noise along with it. Repeater regenerates the desired signal and noise signal will be eliminated. Repeater can be used in the situation where there is a long distance in tr...

InCTF 2014 - Forensics-8 300

Given a partition needed to mount and get the flag. root@Vijay:~/Desktop/inctf 14/forensics# file Forensics-8 Forensics-8: x86 boot sector; partition 1: ID=0xc, starthead 0, startsector 1, 97656 sectors, code offset 0xb8 root@Vijay:~/Desktop/inctf 14/forensics# root@Vijay:~/Desktop/inctf 14/forensics# root@Vijay:~/Desktop/inctf 14/forensics# root@Vijay:~/Desktop/inctf 14/forensics# gparted Forensics-8 ====================== libparted : 2.3 ====================== root@Vijay:~/Desktop/inctf 14/forensics# parted Forensics-8 GNU Parted 2.3 Using /root/Desktop/inctf 14/forensics/Forensics-8 Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) unit                                                             Unit?  [compact]? B                       ...

InCTF 2014 - Reverse 50

1. First Challenge was given python compiled File Used Python decompiler to get the original code. root@Vijay:~/Desktop/inctf 14/reverse# file one one: python 2.7 byte-compiled I got the printable sequence array values. eflag = [131, ... 138, ... 219, ... 198, ... 201, ... 158, ... 151, ... 154, ... 134, ... 129, ... 128, ... 177, ... 135, ... 157, ... 177, ... 157, ... 154, ... 135, ... 130, ... 130, ... 177, ... 141, ... 129, ... 129, ... 130, ... 201, ... 199] >>> eflag [131, 138, 219, 198, 201, 158, 151, 154, 134, 129, 128, 177, 135, 157, 177, 157, 154, 135, 130, 130, 177, 141, 129, 129, 130, 201, 199] >>> >>> flag = ''.join(map(chr, map(lambda x: x ^ 238, eflag))) >>> >>> print flag md5('python_is_still_cool') Next is the compiled java class file, I used jad decompiler to get the original class file root@Vijay:~/Desktop/inctf 14/reverse# file two.class two.class: compiled Java...

InCTF 2014 - Reverse 100

Hi this is my first reverse engineering with GDB. Challenge was to get the flag from the display_function. First we should disassemble the executable file with objdump to see how the program control works. root@Vijay:~/Desktop/inctf 14/reverse# objdump -d four four: file format elf32-i386 Disassembly of section .init: 080482f4 : 80482f4: 53 push %ebx 80482f5: 83 ec 08 sub $0x8,%esp 80482f8: e8 b3 00 00 00 call 80483b0 80482fd: 81 c3 03 1d 00 00 add $0x1d03,%ebx 8048303: 8b 83 fc ff ff ff mov -0x4(%ebx),%eax 8048309: 85 c0 test %eax,%eax 804830b: 74 05 je 8048312 804830d: e8 3e 00 00 00 call 8048350 8048312: 83 c4 08 add $0x8,%esp 8048315: 5b pop %ebx 8048316: c3 ret Disassembly of section .plt: 08048320 : 8048320: ff 35 04 a0 04 08 pushl 0x804a004 8048326: ff 25 08 a0 04 08 jmp ...

InCTF 2014 - Stegnography 400

Give an image, the flag is hidden in the Blue plane. import os,sys import Image modi_bin = Image.open("modi.png").convert('RGB') bin = '' R = open('r.txt','w') G = open('g.txt','w') B = open('b.txt','w') # By Analysing the text docs I found blue Plane First column is embedded with data flag = '' flag1 = '' for h in range(modi_bin.size[1]): # Fetches Height count = 0 binR = '' binG = '' binB = '' for w in range(modi_bin.size[0]): # Fetches Width count += 1 binR += str(modi_bin.getpixel((w,h))[0] & 1) binG += str(modi_bin.getpixel((w,h))[1] & 1) binB += str(modi_bin.getpixel((w,h))[2] & 1) if w == 0: # blue plane first bit flag += str(modi_bin.getpixel((w,h))[2] & 1) if count == 8: R.write(binR) G.write(binG) B.write(binB) binR=' ';binG=' ';binB=' ' count = 0 R.write(binR+'\n') G....

InCTF 2014 - Crypto 300

This is also a RSA challenge which is more interesting, given a RSA-704 bit. Factors are found in the wiki. I used openssl to finish, this challenge. root@Vijay:# openssl rsa -inform PEM -text -pubin -in publickey.pem -modulus Public-Key: (704 bit) Modulus: 00:e1:34:18:93:fe:6e:68:16:ce:c8:a9:70:a3:9c: 00:fa:54:7c:7d:a2:cd:ed:ab:0a:62:b9:1c:46:51: a8:3f:96:38:0b:cf:ae:e2:6f:7e:86:61:07:90:63: 89:42:1b:1e:68:d0:a1:7a:ad:c9:87:0b:98:58:e9: 56:28:6e:39:99:e9:8c:ec:98:81:53:4a:c7:72:ae: 78:f5:e8:ab:a1:e2:f8:d3:03:95:77:02:9d:87 Exponent: 65537 (0x10001) Modulus=E1341893FE6E6816CEC8A970A39C00FA547C7DA2CDEDAB0A62B91C4651A83F96380BCFAEE26F7E866107906389421B1E68D0A17AADC9870B9858E956286E3999E98CEC9881534AC772AE78F5E8ABA1E2F8D3039577029D87 writing RSA key -----BEGIN PUBLIC KEY----- MHQwDQYJKoZIhvcNAQEBBQADYwAwYAJZAOE0GJP+bmgWzsipcKOcAPpUfH2ize2r CmK5HEZRqD+WOAvPruJvfoZhB5BjiUIbHmjQoXqtyYcLmFjpVihuOZnpjOyYgVNK x3KuePXoq6Hi+NMDlXcCnYcCAwEAAQ== -----END PUBLIC KEY-...