Department of Compuetr Science and Engineering: Lab Manual Information Security
Department of Compuetr Science and Engineering: Lab Manual Information Security
Department of Compuetr Science and Engineering: Lab Manual Information Security
; ;; ;; ; ; ; ; ; ; ; ;; ;; ;; ; ; ; ; ; ; ; ; ; ; ; ; ; ;; ;;o;;
;;;;o;;;;;;o;;;;;;;;;;;;;;;;;;;;;;;;;;o
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;.;;
.;;.;;.;;.;;.;;.;;.;;.;;;
();;.;;.;;.;;.;;.;;.;;.;;.;;;);;.;;.;;.;;.;;.;;.;;.;;.;;;.;;.;;.;;.;;.;;.;;.;;.;;.;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;.;;.;;.;;.;;.;;.;;.;;.;;.;
;;.;;.;;.;;.;;.;;.;;.;;.;;.;;;;;o;;;;;;;;;;;;;;;;;;;o;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;.;;;.;;.;;
.;;.;;.;;.;;.;;.;;.;;;.;;.;;.;;.;;.;;.;;.;;.;;.;;;.;;.;;.;;.;;.;;.;;.;;.;;.;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
();;.;;.;;.;;.;;.;;.;;.;;.;;; ;; ;; ;; ; ; ; ; ; ; ; ; ; ; ; ;; ;;o;; ;;
;;;;;;;;;;;;;);;.;;.;;.;; .;;.;;.;;.;;.;;;
();;.;;.;;.;;.;;.;;.;;.;;.;;;;;;;;;;;;;;;;;;;;;;;;o;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
();;.;;.;;.;;.;;.;;.;;.;;.;;;;;o;;;;;;o;;;;;;o;;;;;.;;.;;.;;.;; .;;.;;.;
;.;;.;;;.;;.;;.;;.;;.;;.;;.;;.;;.;;;.;;.;;.;;.;;.;;.;;.;;.;;.;;;.;;.;;.;;.;;.;;.;;.;;.;;.;;;);;.
;;.;;.;;.;;.;;.;;.;;.;;;;;;;;;;;;;;;;;;;;;;.;;.;;.;;.;; .;;.;;.;;
.;;.;;;.;;.;;.;;.;;.;;.;;.;;.;;.;;; DEPARTMENT OF
Date of
Issue:
GNEC/CSE/LAB
MANUAL/ IS[ ]
Compiled
By:
Authorized
By
HOD CSE
Version :1.1
Date of
Revision:
Verified By:
INDEX
S.No
Contents
Lab Objective
Guidelines to Students
Page
no
3
4
6
7
References
8
8
2
LAB OBJECTIVES
Upon successful completion of this lab students will be able to :
1) Socket programming
2) Get an exposure to network sniffers
3) Have an idea to work with different cryptographic algorithms and their
performance evaluation.
4) Exposed to Secure Socket Layers and SSH.
5) Knowledge about e-mail security through S/MIME
6) Exposure to Client Server concept using tcp/ip,blowfish,Pretty Good Privacy.
7) Knowledge about how network conjuction takes place and how buffer overflow
plays an important role.
8) An idea of how firewalls work
RAM
256 MB
Hard Disk
40 GB
Mouse
Optical Mouse
Present
Software
All systems are configured in DUAL BOOT mode i.e, Students can boot from
Windows XP or Linux as per their lab requirement.
This is very useful for students because they are familiar with different
Operating Systems so that they can execute their programs in different
programming environments.
Each student has a separate login for database access
Oracle 9i client version is installed in all systems. On the server, account for
each student has been created.
This is very useful because students can save their work ( scenarios,
pl/sql programs, data related projects ,etc) in their own accounts. Each
student work is safe and secure from other students.
Latest Technologies like DOT NET and J2EE are installed in some
systems. Before submitting their final project, they can start doing mini
project from 2nd year onwards.
Systems are assigned numbers and same system is allotted for students when they
do the lab.
./<Program name>
TCP/IP Hacking
Step1: Same as above steps
Step2: In tcp/ip directory sniffers programs can be executed
Step3: To execute and run the program
C:\> make
C:\> ./sniffer
Step4: output can be checked in text file created due to step3.
S.No
1
2
Page.
No.
8-19
20-31
3
1
3
5
3
6
3
8
39-60
6
1
7
7
0
7
71
72-73
80
9
10
74-79
Algorithm:
Step1: Start
Step2: Declare the following functions
void Handle_ICMP(char *,int)
in.s_addr=ip_hdr->daddr
output(fp,"destination address is %s\n",inet_ntoa(in))
output(fp,"\t --------------------------------\n")
ctl=ip_hdr->protocol
Step16:
Step17:
Step23:
Step24:
fp=fopen("./output/ether.txt","a")
if(!fp)
perror("fopen")
setvbuf(fp,NULL,_IONBF,0)
The following infinite while loop is used to continuously
capture packets and afterwards the packet will be passed
to appropriate handler
Step25:
while(1)
sl=sizeof(struct sockaddr_ll);
retval=recvfrom(sockfd,buf,2000,0,(struct sockaddr *)&sa,&sl)
if(retval==-1)
perror("recvfrom")
eth_hdr=(struct ethhdr *) buf
output(fp,"\t ----------------------------\n")
system("date>>./output/ether.txt")
hadd=ether_ntoa((struct ether_addr *)eth_hdr->h_source)
fprintf(fp,"source ethernet address is %s\n",hadd)
hadd=ether_ntoa((struct ether_addr *)eth_hdr->h_dest)
fprintf(fp,"destination ethernet address is %s\n",hadd)
fprintf(fp,"packet protocol id is %x\n",ntohs(eth_hdr->h_proto))
fprintf(fp,"\t ----------------------------\n")
ctl=ntohs(eth_hdr->h_proto)
switch(ctl)
case 0x0800:
print("received IP packet\n")
Handle_IP(buf)
break
case 0x0806
print("received ARP packet\n")
Handle_ARP(buf)
break
case 0x8035
print("received RARP packet\n")
Handle_RARP(buf)
break
fclose(fp)
Step26:
Step27:
11
Step28:
Step29:
Step30:
Step31:
Step32:
Step33:
Step34:
Step35:
Step36:
13
Step39:
Step40:
switch(ctl)
case ICMP:
Handle_ICMP(buf,len);
break;
case IGMP:
Handle_IGMP(buf,len);
break;
case TCP:
Handle_TCP(buf,len);
break;
case UDP:
Handle_UDP(buf,len);
break;
This file is part of sniffer, a packet capturing utility and
Network Monitor
void Handle_ICMP(char *buf,int len)
declaring pointer of type icmp header
struct icmphdr *icmp_hdr
FILE *fp
fp=fopen("./output/icmp.txt","a")
if(!fp)
perror("icmp.fopen")
Step41:
The following header is used to adjust offset so that icmp header
can point to currect location
icmp_hdr=(struct icmphdr *) (buf+len);
print(fp,"\t --------------------------------\n")
system("date>> ./output/icmp.txt")
print(fp,"message type : %d\n",icmp_hdr->type)
print(fp,"sub-code : %d\n",icmp_hdr->code)
print(fp,"\t --------------------------------\n")
Step 42:
Step43:
Storing ip address in struct in_addr so that we can
execute inet_ntoa() to retreive the same in string
format
Step44:
Step45:
in.s_addr=igmp_hdr->igmp_group.s_addr;
print(fp,"igmp group : %s\n",inet_ntoa(in)
print(fp,"\t ---------------------------------\n")
void Handle_TCP(char *buf,int len)
struct tcphdr *tcp_hdr; // declaring a pointer of type tcp header
FILE *fp
fp=fopen("./output/tcp.txt","a")
if(!fp)
perror("tcp.fopen")
The following statement is used to adjust the offset so that
tcp header pointer can point to currect location
15
Step 46:
Step47:
Step48:
Test Data:
Valid Data Set:
Invalid address
Not applicable
RESULT:
Fri Jul 16 20:03:51 IST 2004
-------------------------------hardware type : 1
protocol type : 2048
hardware length : 6
protocol length : 4
operation code : 1
sender hardware address : 0:2:44:10:f6:41
sender protocol address : 192.168.100.5
target protocol address : 192.168.100.254
--------------------------------Fri Jul 16 20:03:52 IST 2004
-------------------------------hardware type : 1
protocol type : 2048
hardware length : 6
protocol length : 4
operation code : 1
sender hardware address : 0:2:44:10:f6:41
sender protocol address : 192.168.100.5
target protocol address : 192.168.100.254
--------------------------------Fri Jul 16 20:03:53 IST 2004
-------------------------------hardware type : 1
protocol type : 2048
hardware length : 6
protocol length : 4
operation code : 1
sender hardware address : 0:2:44:10:f6:41
sender protocol address : 192.168.100.5
target protocol address : 192.168.100.254
--------------------------------Fri Jul 16 20:03:55 IST 2004
-------------------------------hardware type : 1
protocol type : 2048
hardware length : 6
protocol length : 4
operation code : 1
17
hardware length : 6
protocol length : 4
operation code : 1
sender hardware address : 0:2:44:10:f6:41
sender protocol address : 192.168.100.5
target protocol address : 192.168.100.254
--------------------------------Fri Jul 16 20:04:01 IST 2004
-------------------------------hardware type : 1
protocol type : 2048
hardware length : 6
protocol length : 4
operation code : 1
sender hardware address : 0:2:44:10:f6:41
sender protocol address : 192.168.100.5
target protocol address : 192.168.100.254
--------------------------------Fri Jul 16 20:04:03 IST 2004
-------------------------------hardware type : 1
protocol type : 2048
hardware length : 6
protocol length : 4
operation code : 1
sender hardware address : 0:2:44:10:f6:41
sender protocol address : 192.168.100.5
target protocol address : 192.168.100.254
--------------------------------Fri Jul 16 20:04:04 IST 2004
-------------------------------hardware type : 1
protocol type : 2048
hardware length : 6
protocol length : 4
operation code : 1
sender hardware address : 0:2:44:10:f6:41
sender protocol address : 192.168.100.5
target protocol address : 192.168.100.254
--------------------------------Fri Jul 16 20:04:05 IST 2004
--------------------------------
19
hardware type : 1
protocol type : 2048
hardware length : 6
protocol length : 4
operation code : 1
sender hardware address : 0:2:44:10:f6:41
sender protocol address : 192.168.100.5
target protocol address : 192.168.100.254
--------------------------------Fri Jul 16 20:04:07 IST 2004
-------------------------------hardware type : 1
protocol type : 2048
hardware length : 6
protocol length : 4
operation code : 1
sender hardware address : 0:2:44:10:f6:41
sender protocol address : 192.168.100.5
target protocol address : 192.168.100.254
--------------------------------Fri Jul 16 20:04:08 IST 2004
-------------------------------hardware type : 1
protocol type : 2048
hardware length : 6
protocol length : 4
operation code : 1
sender hardware address : 0:2:44:10:f6:41
sender protocol address : 192.168.100.5
target protocol address : 192.168.100.254
--------------------------------Fri Jul 16 20:04:22 IST 2004
-------------------------------hardware type : 1
protocol type : 2048
hardware length : 6
protocol length : 4
operation code : 1
sender hardware address : 0:50:bf:d8:48:a1
sender protocol address : 192.168.100.2
target protocol address : 192.168.100.1
---------------------------------
(2)
Algorithm:
Step1:
Start
21
Test Data:
Valid Data Set:
Not applicable
Result:
23
key111111100010010011101000000101110110110100110111
101101001101100000010011110001111000011000111010
0110temp is 1
0110temp is 8
0000temp is 13
1001temp is 7
1000temp is 6
1100temp is 1
1100temp is 5
1101temp is 3
b1 is
0001
1000
1101
0111
0110
0001
0101
0011
00011000110101110110000101010011after substn
10000110010111110011100110000010xor l[i] with res[i]
left and right for next round
10010111100111011010011101100110
10000110010111110111100110010001r1:
110000001100001011111110101111110011110010100011
key110110101100111000111000011011110000100111010100
000110100000110011000110110100000011010101110111
0011temp is 1
0000temp is 0
1001temp is 15
0011temp is 3
1010temp is 12
0001temp is 15
1010temp is 5
1011temp is 0
b1 is
0001
0000
1111
0011
1100
1111
0101
0000
00010000111100111100111101010000after substn
10010111011101010010000100001110xor l[i] with res[i]
left and right for next round
10000110010111110111100110010001
00000000111010001000011001101000r1:
000000000001011101010001010000001100001101010000
key110011001011101100011110110000011110000111011111
110011001010110001001111100000010010001010001111
1001temp is 11
0101temp is 11
1000temp is 4
0111temp is 3
0000temp is 4
1001temp is 13
0101temp is 0
0111temp is 4
b1 is
1011
1011
0100
0011
0100
1101
0000
0100
10111011010000110100110100000100after substn
11010000110011010110001000101010xor l[i] with res[i]
left and right for next round
00000000111010001000011001101000
01010110100100100001101110111011r1:
101010101101010010100100000011110111110111110110
key001001101011111001001111011001111001011010001101
100011000110101011101011011010001110101101111011
0001temp is 12
0011temp is 14
0101temp is 9
0101temp is 1
25
1101temp is 0
0111temp is 8
0110temp is 10
1101temp is 5
b1 is
1100
1110
1001
0001
0000
1000
1010
0101
11001110100100010000100010100101after substn
11010100100010001000110100110001xor l[i] with res[i]
left and right for next round
01010110100100100001101110111011
11010100011000000000101101011001r1:
111010101000001100000000000001010110101011110011
key011010110111110001100010110110100001010111101111
100000011111111101100010110111110111111100011100
0000temp is 4
1111temp is 5
1110temp is 2
0001temp is 6
1011temp is 9
1011temp is 7
1110temp is 9
1110temp is 12
b1 is
0100
0101
0010
0110
1001
0111
1001
1100
01000101001001101001011110011100after substn
00101011011000001111000000111101xor l[i] with res[i]
left and right for next round
11010100011000000000101101011001
01111101111100101110101110000110r1:
001111111011111110100101011101010111110000001100
key111010001110110111111000000011101101101110101101
110101110101001001011101011110111010011110100001
1010temp is 3
1010temp is 7
0100temp is 3
1110temp is 14
1111temp is 9
1101temp is 13
1111temp is 1
0000temp is 2
b1 is
0011
0111
0011
1110
1001
1101
0001
0010
00110111001111101001110100010010after substn
01110111010000100111001001011110xor l[i] with res[i]
left and right for next round
01111101111100101110101110000110
10100011001000100111100100000111r1:
110100000110100100000100001111110010100000001111
key110101001110011100011011010100100111110111110001
000001001000111000011111011011010101010111111110
0000temp is 0
0100temp is 6
1100temp is 5
1111temp is 9
1101temp is 9
1010temp is 13
1011temp is 12
1111temp is 8
b1 is
0000
27
0110
0101
1001
1001
1101
1100
1000
00000110010110011001110111001000after substn
11111101000100010010000001011001xor l[i] with res[i]
left and right for next round
10100011001000100111100100000111
10000000111000111100101111011111r1:
110000000001011100000111111001010111111011111111
key101111100100101111100110111011001111100001010111
011111100101110011100001000010011000011010101000
1111temp is 8
0010temp is 10
1001temp is 15
0000temp is 3
0001temp is 12
1100temp is 14
1101temp is 10
0100temp is 9
b1 is
1000
1010
1111
0011
1100
1110
1010
1001
10001010111100111100111010101001after substn
11011101111011010000110100001101xor l[i] with res[i]
left and right for next round
10000000111000111100101111011111
01111110110011110111010000001010r1:
001111111101011001011110101110101000000001010100
key101110100111001100101001101001111100011011111010
100001011010010101110111000111010100011010101110
0000temp is 15
1101temp is 0
1010temp is 5
1011temp is 11
0011temp is 12
1010temp is 3
1101temp is 10
0111temp is 2
b1 is
1111
0000
0101
1011
1100
0011
1010
0010
11110000010110111100001110100010after substn
10000101111001111010011001000011xor l[i] with res[i]
left and right for next round
01111110110011110111010000001010
00000101000001000110110110011100r1:
000000001010100000001000001101011011110011111000
key100010010001011101111101100111011001111101000011
100010011011111101110101101010000010001110111011
0001temp is 1
1101temp is 9
1110temp is 2
1010temp is 5
0101temp is 13
0001temp is 1
0111temp is 13
1101temp is 5
b1 is
0001
1001
0010
0101
1101
0001
1101
29
0101
00011001001001011101000111010101after substn
10100011000111000111100000100111xor l[i] with res[i]
left and right for next round
00000101000001000110110110011100
11011101110100110000110000101101r1:
111011111011111010100110100001011000000101011011
key110001010101101011011101100111101100011001110100
001010101110010001111011000110110100011100101111
0101temp is 15
0111temp is 1
1000temp is 2
1101temp is 7
0011temp is 1
1010temp is 4
1110temp is 6
0111temp is 13
b1 is
1111
0001
0010
0111
0001
0100
0110
1101
11110001001001110001010001101101after substn
10101000110100001101111000101110xor l[i] with res[i]
left and right for next round
11011101110100110000110000101101
10101101110101001011001110110010r1:
010101011011111010101001010110100111110110100101
key000101111111101111100000010110011110111111000100
010000100100010101001001000000111001001001100001
1000temp is 3
0010temp is 7
1010temp is 5
0100temp is 6
0000temp is 2
1100temp is 6
0100temp is 4
0000temp is 2
b1 is
0011
0111
0101
0110
0010
0110
0100
0010
00110111010101100010011001000010after substn
01000100011100110101001010011010xor l[i] with res[i]
left and right for next round
10101101110101001011001110110010
10011001101000000101111010110111r1:
110011110011110100000000001011111101010110101111
key100110100111110111100011101110001110010010011001
010101010100000011100011100101110011000100110110
1010temp is 12
1010temp is 2
0001temp is 7
0001temp is 15
0010temp is 12
1001temp is 14
0010temp is 2
1011temp is 13
b1 is
1100
0010
0111
1111
1100
1110
0010
1101
11000010011111111100111000101101after substn
11011101111001011001110001101100xor l[i] with res[i]
left and right for next round
10011001101000000101111010110111
01110000001100010010111111011110r1:
31
001110100000000110100010100101011111111011111100
key111110010110011101001101111010110111011000000111
110000110110011011101111011111101000100011111011
1000temp is 15
1011temp is 6
1101temp is 11
0111temp is 8
1111temp is 6
0100temp is 2
0001temp is 11
1101temp is 5
b1 is
1111
0110
1011
1000
0110
0010
1011
0101
11110110101110000110001010110101after substn
01000110101001001000111111110111xor l[i] with res[i]
left and right for next round
01110000001100010010111111011110
11011111000001001101000101000000r1:
011011111110100000001001011010100010101000000001
key001011110011110010111110001010111001101110110011
010000001101010010110111010000011011000110110010
1000temp is 3
0110temp is 8
1001temp is 13
1011temp is 11
1000temp is 8
1101temp is 11
0011temp is 14
1001temp is 6
b1 is
0011
1000
1101
1011
1000
1011
1110
0110
00111000110110111000101111100110after substn
10010101011110110010011101100011xor l[i] with res[i]
left and right for next round
11011111000001001101000101000000
11100101010010100000100010111101
after swapping
1110010101001010000010001011110111011111000001001101000101000000outpu
t is
1100100110010000111000011001010110001001010000011101101011001001
Algorithm:
Generate Your Private Key
33
Not applicable
Not applicable
Not applicable
Result:
cat server.csr
35
Viva-Voce Questions:
What is open SSL.
Explain the architecture of secure socket layer
What are the two services that SSl recprd protocol provides.
How many keys are used in open ssl communication
37
How does a cipher text look in openssl after first key use
Algorithm:
Step1: Start
Step2: read int listfd,connfd,retval
pid_t childpid
socklen_t clilen
struct sockaddr_in cliaddr, servaddr
listfd = socket(AF_INET, SOCK_STREAM, 0)
Step3: if (listfd < 0)
perror("sock:")
bzero(&servaddr, sizeof(servaddr))
servaddr.sin_family = AF_INET
servaddr.sin_addr.s_addr = htonl(INADDR_ANY)
servaddr.sin_port = htons(8000)
retval = bind(listfd, (struct sockaddr *) &servaddr,
sizeof(servaddr))
Step4 : if(retval < 0)
perror("bind:")
listen(listfd, 5)
Step5:
while(1)
clilen = sizeof(cliaddr)
connfd = accept(listfd, (struct sockaddr *) &cliaddr,
&clilen)
print(" client connected \n")
print("
client's
%d\n",htons(cliaddr.sin_port))
Step6:
port
no
int sockfd,ret_val
39
Stop
Test Data:
Valid Data Set:
Invalid IP address
Not applicable
What is PGP?
Explain the PGP services.
How is confidentiality and authentication in PGP
cryptographic function?
What is session key
Explain how secure hash function helps in PGP
Turbo C
Pentium IV Processor, 256 MB RAM,40 GB HDD.
Algorithm:
41
Step1: Start
Step2: unsigned long F(BLOWFISH_CTX *ctx, unsigned int x)
unsigned short a, b, c, d
unsigned int y
d = x & 0x00FF
x >>= 8
c = x & 0x00FF
x >>= 8
b = x & 0x00FF
x >>= 8
a = x & 0x00FF
y = ctx->S[0][a] + ctx->S[1][b]
y = y ^ ctx->S[2][c]
y = y + ctx->S[3][d]
return y
Step3:
Xr = F(ctx, Xl) ^ Xr
temp = Xl
Xl = Xr
Xr = temp
temp = Xl
Xl = Xr
Xr = temp
Xr = Xr ^ ctx->P[N]
Xl = Xl ^ ctx->P[N + 1]
*xl = Xl
*xr = Xr
Step4:
43
temp = Xl
Xl = Xr
Xr = temp
Xr = Xr ^ ctx->P[1]
Xl = Xl ^ ctx->P[0]
*xl = Xl
*xr = Xr
Step5:
datal = 0x00000000
datar = 0x00000000
for (i = 0; i < N + 2; i += 2)
Blowfish_Encrypt(ctx, &datal, &datar)
ctx->P[i] = datal
ctx->P[i + 1] = datar
for (i = 0; i < 4; ++i)
for (j = 0; j < 256; j += 2)
Blowfish_Encrypt(ctx, &datal, &datar)
ctx->S[i][j] = datal
ctx->S[i][j + 1] = datar
int Blowfish_Test(BLOWFISH_CTX *ctx)
unsigned int L = 1, R = 2
Blowfish_Init(ctx, (unsigned char*)"TESTKEY", 7)
Blowfish_Encrypt(ctx, &L, &R)
if (L != 0xDF333FD2L || R != 0x30A71BB4L) return (-1)
Blowfish_Decrypt(ctx, &L, &R)
if (L != 1 || R != 2) return (-1); return (0)
extern unsigned char ciphertext_buffer[256]
extern unsigned char *ciphertext_string
int startEncryption(char *plaintext_string,char *key)
BLOWFISH_CTX ctx
unsigned int message_left
unsigned int message_right
int keylen=strlen(key)
45
int block_len,plaintext_len=strlen(plaintext_string)
int ciphertext_len=0
ciphertext_string=&ciphertext_buffer[0]
Blowfish_Init(&ctx, (unsigned char *)key, keylen)
print("Plaintext message string is: %s\n", plaintext_string)
Step 6: encrypt the plaintext message string
print("Encrypted message string is: ")
while (plaintext_len)
message_left = message_right = 0UL
Step7:
Step8:
Step10:
47
Step12:
BLOWFISH_CTX
static const unsigned long ORIG_P[16 + 2] =
0x85A308D3L, 0x13198A2EL, 0x03707344L,
0x243F6A88L,
Step15:
unsigned int Xl
unsigned int Xr
unsigned int temp
int ii,i
Xl = *xl
Xr = *xr;
for (i = 0; i < N; ++i)
Xl = Xl ^ ctx->P[i]
Xr = F(ctx, Xl) ^ Xr
temp = Xl
Xl = Xr
Xr = temp
temp = Xl
Xl = Xr
Xr = temp
Xr = Xr ^ ctx->P[N]
Xl = Xl ^ ctx->P[N + 1]
*xl = Xl
*xr = Xr
Step16:
Xl = *xl
Xr = *xr
for (i = N + 1; i > 1; --i)
Xl = Xl ^ ctx->P[i]
Xr = F(ctx, Xl) ^ Xr
temp = Xl
Xl = Xr
Xr = temp
temp = Xl
Xl = Xr
Xr = temp
Xr = Xr ^ ctx->P[1]
Xl = Xl ^ ctx->P[0]
*xl = Xl
*xr = Xr
Step17:
67
data = 0x00000000
for (k = 0; k < 4; ++k)
data = (data << 8) | key[j]
j=j+1
if (j >= KeyLen)
j=0
ctx->P[i] = ORIG_P[i] ^ data;
datal = 0x00000000
datar = 0x00000000
for (i = 0; i < N + 2; i += 2)
Step 18:
Step19:
Step20:
extern char
plain_buffer[256]
extern char
*plain_string
ciphertext_len=0
ciphertext_string=&ciphertext_buffer[0]
Blowfish_Init(&ctx, (unsigned char *)key, keylen)
print("Plaintext message string is: %s\n", plaintext_string)
Step21:
Step22:
crack the message string into a 64-bit block (ok, really two 32-bit
blocks); pad with zeros if necessary
for (block_len = 0; block_len < 4; block_len++)
message_left = message_left << 8
if (plaintext_len)
message_left += *plaintext_string++
69
plaintext_len-else message_left += 0
for (block_len = 0; block_len < 4; block_len++)
message_right = message_right << 8
if (plaintext_len)
message_right += *plaintext_string++
plaintext_len-else message_right += 0
Step23:
Step24:
int
startDecryption(unsigned
ciphertext_len,char *key)
char
*ciphertext_string,char
BLOWFISH_CTX ctx
unsigned int message_left
unsigned int message_right
int block_len
int keylen=strlen(key)
int plain_stringLen=0
plain_string=&plain_buffer[0]
Blowfish_Init(&ctx, (unsigned char *)key, keylen)
printf("Decrypted message string is: ")
print("cipher Len: %d\n",ciphertext_len)
while(ciphertext_len)
message_left = message_right = 0UL
for (block_len = 0; block_len < 4; block_len++)
message_left = message_left << 8
message_left += *ciphertext_string++
if (ciphertext_len)
ciphertext_len-for (block_len = 0; block_len < 4; block_len++)
message_right = message_right << 8
message_right += *ciphertext_string++
if (ciphertext_len)
ciphertext_len-Step25:
71
Stop
Test Data:
Valid Data Set:
Not applicable
Not applicable
H/W:
ALGORITHM
rc.test-iptables.txt
The rc.test-iptables.txt
(http://iptables-tutorial.frozentux.net/scripts/rc.test-iptables.txt) script
can be used to test all the different chains, but it might need some
tweaking depending on your configuration, such as turning on
ip_forwarding, and setting up masquerading etc. It will work for most
everyone who has all the basic set up and all the basic tables loaded
into kernel. All it really does is set some LOG targets which will log ping
replies and ping requests. This way, you will get information on which
chain was traversed and in which order. For example, run this script and
then do:
ping -c 1 host.on.the.internet
And tail -n 0 -f /var/log/messages while doing the first command. This
should show you all the different chains used, and in which order,
unless the log entries are swapped around for some reason.
This script was written for testing purposes only. In other words, its not a
good idea to have rules like this that log everything of one sort since your
log partitions might get filled up quickly and it would be an effective Denial
of Service attack against you and might lead to real attacks on you that
would be unlogged after the initial Denial of Service attack.
rc.flush-iptables.txt
The rc.flush-iptables.txt
(http://iptables-tutorial.frozentux.net/scripts/rc.flush-iptables.txt) script
should not really be called a script in itself. The rc.flush-iptables.txt
(http://iptables-tutorial.frozentux.net/scripts/rc.flush-iptables.txt) script
will reset and flush all your tables and chains. The script starts by
setting the default policies to ACCEPT on the INPUT, OUTPUT and
FORWARD chains of the filter table. After this we reset the default
policies of the PREROUTING, POSTROUTING and OUTPUT chains of
the nat table. We do this first so we wont have to bother about closed
connections and packets not getting through. This script is intended for
actually setting up and troubleshooting your firewall, and hence we only
care about opening the whole thing up and resetting it to default values.
After this we flush all chains first in the filter table and then in the NAT
table. This way we know there are no redundant rules lying around
anywhere. When all of this is done, we jump down to the next section
where we erase all the user specified chains in the NAT and filter
tables. When this step is done, we consider the script done. You may
consider adding rules to flush your mangle table if you use it.
One final word on this issue. Certain people have mailed me asking me to
put this script into the original rc.firewall script using Red Hat Linux syntax
where you type something like rc.firewall start and the script starts.
However, I will not do that since this is a tutorial and should be used as a
place to fetch ideas mainly and it shouldnt be filled up with shell scripts
and strange syntax. Adding shell script syntax and other things makes the
script harder to read as far as I am concerned and the tutorial was written
with readability in mind and will continue being so.
Test Data:
Valid Data Set:
Not applicable
Not applicable
Not applicable
Result:
Linux will have IP tables
C:\> apropos IP/apropos IPtab*
C:\> where is iptables
Note: Depending on rehat version as 2.4,2.6
C:\> yom i install iptables.rpm
C:\> optget i install iptables
C:\> man squid
C:\> iptables h
C:\> gip
C:\> kip
75
Algorithm:
MIME-Version: Must be 1.0 -> RFC 2045, RFC 2046
Content-Type: More types being added by developers (application/word)
Content-Transfer-Encoding: How message has been encoded (radix-64)
Content-ID: Unique identifying character string.
Content Description: Needed when content is not readable text (e.g.,mpeg)
Test Data:
Valid Data Set:
Not applicable
Not applicable
Not applicable
77
Algorithm:
Introduction
Most deadly weapon on the Internet.
Try to gain partial or complete control over target computer by creating a back
door entry.
Enable the attacker to execute a malicious code on target system.
Gives root or super access to attacker.
How it Works
Due to casual or careless programming
Poor Memory Management
Mismanagement of system variables, pointers and temporary data.
-by application developers.
THE OVERALL PROCESS:Identify a vulnerable application.
Inject the malicious code.
Execute the code.
THE OVERALL PROCESS:Identify a vulnerable application.
Inject the malicious code.
Execute the code.
Format String Overflows:-
Not applicable
Not applicable
Not applicable
79
ALGORITHM
Nmap features include:
Ping Sweeping- Identifying computers on a network, for example listing the
computers which respond to pings, or which have a particular port open
Port Scanning - Enumerating the open ports on one or more target computers
OS Detection - Remotely determining the operating system and some hardware
characteristics of network devices.
Nmap command line prompt:
C:\nmap> nmap -sP 192.168.0.10
Well-Known Ports:
Ports numbered 0 to 1023 are considered well known (also called standard ports) and
are assigned to services by the IANA (Internet Assigned Numbers Authority). Here
are a few samples:
21 FTP
80 HTTP
110 POP
Table:Scans available through nmap:
Scan Type
Switch
Description
-sT
TCP
connect()
scan
TCP
SYN -sS
scan
Stealth FIN
-sF
This scan attempts to pass through packet filters by sending a TCP FIN
packet.
Xmas Tree
-sX
Null
-sN
Ping
-sP
This limits the scan to only conducting a ping sweep to look for
connected systems. It does not do port scans.
UDP scan
-sU
This sends 0 byte UDP packets to each port on the target machine(s).
ACK scan
-sA
This scan is used to help check packet filters. An ACK packet with
random acknowledgment and sequence numbers is sent. If nothing is
returned, the port is marked as filtered.
List scan
-sL
The "half-open" scan. This scan sends a TCP SYN packet as though it
is trying to open the connection. If it receives a SYN-ACK response, it
sends an immediate RST to shut down the connection. Because this
scan doesn't open the connection, it is less likely to be logged.
sending a
<ftp This scan relives a historical foible of FTP servers. Older FTP servers
FTP bounce -b
relay host>
scan
were able to serve bounced FTP sessions; that is, they connected to
another host to deliver data to you. By providing a relay host in the
format username:password@server:port, you can use this FTP
bounce (mis)feature to scan ports that might otherwise be protected.
81
Easy to implement
Accurate
Cons:
Easily detected
Traceable
Nmap command line prompt:
C:\nmap> nmap -sS 192.168.0.10
Pros:
Fast
Accurate
Fairly easy to implement
Harder to trace than the TCP connect port-scan method
Cons:
Not totally stealthy
Easily blocked
Nmap command line prompt:
C:\nmap> nmap -sF 192.168.0.7
Pros:
Fairly fast
Easy to implement
Stealthy to a certain extent
Cons:
Inaccurate with certain operating systems
Nmap command line prompt:
C:\nmap> nmap -sX 192.168.0.7
Nmap command line prompt:
C:\nmap> nmap -sN 192.168.0.7
Pros:
Fairly fast
Easy to implement
Stealthy to a certain extent
Cons:
Works only with UNIX and some other operating systems
Nmap command line prompt:
C:\nmap> nmap -sU 192.168.0.10
Nmap command line prompt:
C:\nmap> nmap -sA 68.46.234.161
Nmap command line prompt:
C:\nmap> nmap -sA 68.46.234.161
Option
Explanation
-P0
-f
-v
-oN
<logfile>
-oM
<logfile>
--resume
<logfile&;
-iL <logfile>
-g <portnumber>
83
Option
Explanation
-p <port range>
Test Data:
Valid Data Set:
IP address
Invalid IP address
Not applicable
Result:
Nmap command line prompt:
C:\nmap> nmap -O www.hackingmobilephones.com
85
ALGORITHM:
/sbin/iptables F INPUT
/sbin/iptables F OUTPUT
/sbin/iptables t filter-F FORWARD
/sbin/iptables P INPUT DROP
/sbin/iptables P OUTPUT ACCEPT
/sbin/iptables P FORWARD DROP
Iptables - A INPUT i eth0 state state RELATED ,ESTABLISHED J ACCEPT
iptables - A FORWARD i eth0 state state RELATED ,ESTABLISHED J
ACCEPT
iptables - A FORWARD i eth1 J ACCEPT
iptables - A FORWARD i eth0 p tcp dport 80 d 200.0.2.1 J ACCEPT
iptables - A FORWARD i eth0 p tcp dport telnet d 200.0.2.1 J ACCEPT
iptables- A INPUT I eth0 p tcp dport http j ACCEPT
iptables- A INPUT I eth0 p tcp dport ssh j ACCEPT
Test Data:
Valid Data Set:
IP Table
Invalid IP table
Not applicable
87
References:
Books:
Web Sites:
1. http://linuxcommand.org/man_pages/openssl1.html
2. http://www.openssl.org/docs/apps/openssl.html
3. http://www.queen.clara.net/pgp/art3.html
4. http://www.ccs.ornl.gov/~hongo/main/resources/contrib/gpg-howto/gpghowto.html
5. https://netfiles.uiuc.edu/ehowes/www/gpg/gpg-com-0.htm
6. http://www.ethereal.com/docs/user-guide/
89