· 6 years ago · Apr 29, 2019, 09:26 AM
1Programs:
2///////////////////////////////Caesar Cipher:
3
4# encrypt and decrypt a text using a simple algorithm of offsetting the letters
5
6key = 'abcdefghijklmnopqrstuvwxyz'
7
8def encrypt(n, plaintext):
9 """Encrypt the string and return the ciphertext"""
10 result = ''
11
12 for l in plaintext.lower():
13 try:
14 i = (key.index(l) + n) % 26
15 result += key[i]
16 except ValueError:
17 result += l
18
19 return result.lower()
20
21def decrypt(n, ciphertext):
22 """Decrypt the string and return the plaintext"""
23 result = ''
24
25 for l in ciphertext:
26 try:
27 i = (key.index(l) - n) % 26
28 result += key[i]
29 except ValueError:
30 result += l
31
32 return result
33
34text = "I am coding Python on SoloLearn!"
35offset = 5
36
37encrypted = encrypt(offset, text)
38print('Encrypted:', encrypted)
39
40decrypted = decrypt(offset, encrypted)
41print('Decrypted:', decrypted)
42
43
44////////////////////////////Transposition Cipher
45// CPP program for illustrating
46// Columnar Transposition Cipher
47#include<bits/stdc++.h>
48using namespace std;
49
50// Key for Columnar Transposition
51string const key = "HACK";
52map<int,int> keyMap;
53
54void setPermutationOrder()
55{
56 // Add the permutation order into map
57 for(int i=0; i < key.length(); i++)
58 {
59 keyMap[key[i]] = i;
60 }
61}
62
63// Encryption
64string encryptMessage(string msg)
65{
66 int row,col,j;
67 string cipher = "";
68
69 /* calculate column of the matrix*/
70 col = key.length();
71
72 /* calculate Maximum row of the matrix*/
73 row = msg.length()/col;
74
75 if (msg.length() % col)
76 row += 1;
77
78 char matrix[row][col];
79
80 for (int i=0,k=0; i < row; i++)
81 {
82 for (int j=0; j<col; )
83 {
84 if(msg[k] == '\0')
85 {
86 /* Adding the padding character '_' */
87 matrix[i][j] = '_';
88 j++;
89 }
90
91 if( isalpha(msg[k]) || msg[k]==' ')
92 {
93 /* Adding only space and alphabet into matrix*/
94 matrix[i][j] = msg[k];
95 j++;
96 }
97 k++;
98 }
99 }
100
101 for (map<int,int>::iterator ii = keyMap.begin(); ii!=keyMap.end(); ++ii)
102 {
103 j=ii->second;
104
105 // getting cipher text from matrix column wise using permuted key
106 for (int i=0; i<row; i++)
107 {
108 if( isalpha(matrix[i][j]) || matrix[i][j]==' ' || matrix[i][j]=='_')
109 cipher += matrix[i][j];
110 }
111 }
112
113 return cipher;
114}
115
116// Decryption
117string decryptMessage(string cipher)
118{
119 /* calculate row and column for cipher Matrix */
120 int col = key.length();
121
122 int row = cipher.length()/col;
123 char cipherMat[row][col];
124
125 /* add character into matrix column wise */
126 for (int j=0,k=0; j<col; j++)
127 for (int i=0; i<row; i++)
128 cipherMat[i][j] = cipher[k++];
129
130 /* update the order of key for decryption */
131 int index = 0;
132 for( map<int,int>::iterator ii=keyMap.begin(); ii!=keyMap.end(); ++ii)
133 ii->second = index++;
134
135 /* Arrange the matrix column wise according
136 to permutation order by adding into new matrix */
137 char decCipher[row][col];
138 map<int,int>::iterator ii=keyMap.begin();
139 int k = 0;
140 for (int l=0,j; key[l]!='\0'; k++)
141 {
142 j = keyMap[key[l++]];
143 for (int i=0; i<row; i++)
144 {
145 decCipher[i][k]=cipherMat[i][j];
146 }
147 }
148
149 /* getting Message using matrix */
150 string msg = "";
151 for (int i=0; i<row; i++)
152 {
153 for(int j=0; j<col; j++)
154 {
155 if(decCipher[i][j] != '_')
156 msg += decCipher[i][j];
157 }
158 }
159 return msg;
160}
161
162// Driver Program
163int main(void)
164{
165 /* message */
166 string msg = "Geeks for Geeks";
167
168 setPermutationOrder();
169
170 // Calling encryption function
171 string cipher = encryptMessage(msg);
172 cout << "Encrypted Message: " << cipher << endl;
173
174 // Calling Decryption function
175 cout << "Decrypted Message: " << decryptMessage(cipher) << endl;
176
177 return 0;
178}
179
180
181//////////////////////////////Auto_key substitution cipher
182
183import math
184import random
185
186def subscipher_encrypt(msg,key):
187 msg = "".join(msg.split(' '))
188 msg = msg.lower()
189 m = list(msg)
190 stage1 = [ord(i) - ord('a') for i in m]
191 stage2 = [key]
192 stage2.extend(stage1[:-1])
193 stage3 = [i+j for i,j in zip(stage1,stage2)]
194 stage4 = [i%26 for i in stage3]
195 stage5 = [chr(i+ord('a')) for i in stage4]
196 cipher = "".join(stage5).upper()
197 return cipher
198
199def subscipher_decrypt(cipher,key):
200 m = list(cipher)
201 stage1 = [ord(i)-ord('A') for i in m]
202 stage2 = [(stage1[0]-key)%26]
203 for i in range(1,len(m)):
204 stage2.append((stage1[i] - stage2[i-1]) % 26)
205 stage3 = [chr(i + ord('A')) for i in stage2]
206 plain = "".join(stage3)
207 return plain
208
209if __name__ == '__main__':
210 message = input("Enter the message : ")
211 key = random.randint(50,100)
212
213
214 ct = subscipher_encrypt(message,key)
215 print("encrypted text is : ",ct)
216 pt = subscipher_decrypt(ct,key)
217 print("Decrypted text is : ",pt)
218
219
220//////////////////////Keyless Transposition Cipher
221
222''' Keyless Transposition Cipher '''
223import math
224
225#WORKING
226''' e.g. message is 'Python' to be transposed
227In keyless trans.n message is split into 2 rows having alternate characters of message
2281st row --> | P | | T | | O | |
2292nd row --> | | Y | | H | | N |
230The transposed message will be all characters of 1st row then of the 2nd row
231i.e. --> 'PTOYHN'
232'''
233
234def encrTrans(m):
235 #For storing characters present at even indices
236 even = []
237 #For storing characters present at odd indices
238 odd = []
239 for i in range(0,len(m)):
240 if(i%2 == 0):
241 even.append(m[i])
242 else:
243 odd.append(m[i])
244 tlist = even + odd
245 #returning list elements as a single string
246 return "".join(tlist)
247
248def decrTrans(tlist):
249 decryptedList = []
250 #halflength means till all the characters which were in the 1st row
251 halflength = math.ceil(len(tlist)/2)
252 #Now we will append characters in decryptedList alternately from 1st half and 2nd half of tlist
253 for i in range(0,halflength):
254 decryptedList.append(tlist[i])
255 if(halflength+i > len(tlist)-1):
256 break
257 else:
258 decryptedList.append(tlist[halflength+i])
259 return decryptedList
260
261if __name__ == '__main__':
262 message = input("Enter the message : ")
263 #Removing spaces if present in the message
264 message = "".join(message.split(' '))
265
266 transposedmsg = encrTrans(message)
267 print("Transposed message is : ",transposedmsg)
268
269 decryptedmsg = decrTrans(transposedmsg)
270 print("Decrypted message is : ","".join(decryptedmsg))
271
272////////////////////firewall using Iptables
273*************list rules
274iptables -L
275*****block ping request (add rule)
276$ sudo iptables -A INPUT -p icmp --icmp-type echo-request -j REJECT
277
278********unblock ping request (delete rule)
279$ sudo iptables -D INPUT -p icmp --icmp-type echo-request -j REJECT
280
281***********block websites
282iptables -A OUTPUT -p tcp -m string --string "sitename.com" --algo kmp -j REJECT
283***********unblock websites
284iptables -D OUTPUT -p tcp -m string --string "sitename.com" --algo kmp -j REJECT
285
286////////////////////////////DEFFI HELLMAN
287******************server.py
288import random
289import socket
290
291def send_R2_receive_R1(R2):
292 try:
293 host = 'localhost'
294 port = 6766
295
296 s = socket.socket()
297 s.bind((host, port))
298 s.listen(1)
299 c, addr = s.accept()
300 data = c.recv(1024)
301 data1 = str(R2)
302 c.send(data1.encode())
303 return int(str(data.decode()))
304 finally:
305 c.close()
306
307def check_primitive(g,p):
308 another_set=set()
309 for e in range(1,p):
310 another_set.add(pow(g,e,p))
311 for i in range(1,p):
312 if i not in another_set:
313 return False
314 return True
315
316if __name__ == '__main__':
317 g, p=int(input("Enter g:")), int(input("Enter p:"))
318 if not check_primitive(g,p):
319 print(g," is not primitive root of ",p,sep="")
320 else:
321 #x = random.randint(1,p)
322 y = random.randint(1,p)
323 #R1 = pow(g,x,p)
324 R2 = pow(g,y,p)
325 print("Found R2 =",R2)
326 R1 = send_R2_receive_R1(R2)
327 print("Received R1 =",R1)
328 key = pow(R1,y,p)
329 print("Key =",key)
330
331*************************client .py
332import random
333import socket
334
335def send_R1_receive_R2(R1):
336 host = 'localhost'
337 port = 6766
338
339 s = socket.socket()
340 s.connect((host, port))
341
342 R1 = str(R1)
343 s.send(R1.encode())
344
345 data = s.recv(1024)
346 data = data.decode()
347
348 s.close()
349 return int(data)
350
351def check_primitive(g,p):
352 another_set=set()
353 for e in range(1,p):
354 another_set.add(pow(g,e,p))
355 for i in range(1,p):
356 if i not in another_set:
357 return False
358 return True
359
360
361if __name__ == '__main__':
362 g, p=int(input("Enter g:")), int(input("Enter p:"))
363 if not check_primitive(g,p):
364 print(g," is not primitive root of ",p,sep="")
365 else:
366 x = random.randint(1,p)
367 #y = random.randint(1,p)
368 R1 = pow(g,x,p)
369 print("Found R1 =",R1)
370 #R2 = pow(g,y,p)
371 R2 = send_R1_receive_R2(R1)
372 print("Received R2 =",R2)
373 key = pow(R2,x,p)
374 print("Key =",key)
375
376////////////////////////////RSA.py
377
378import math
379from sympy import factorint #pip install sympy
380
381factors=[]
382power=[]
383'''
384def isPrime(p):
385 for i in range(2,p//2+1):
386 if p%i==0:
387 return False
388 return True
389
390def factorize(m):
391 i=2
392 k=0
393 while (i<=m):
394 if(isPrime(i)):
395 if m%i==0:
396 factors.append(i)
397 power.append(0)
398 while m%i==0:
399 power[k]+=1
400 m=m//i
401 k+=1
402 i+=1
403 print(factors)
404 print(power)
405'''
406def calc_phi():
407 phi=1
408 for i in range(0,len(factors)):
409 if power[i]>1:
410 phi*=(pow(factors[i], power[i]) - pow(factors[i], power[i]-1))
411 elif power[i]==1:
412 phi*=(factors[i]-1)
413 return phi
414
415def mul_inv(e,n):
416 if(math.gcd(e,phi)==1):
417 r1=phi
418 r2=e
419 t1=0
420 t2=1
421
422 while(r2!=0):
423 q=r1//r2
424 r=r1%r2
425 t=t1-q*t2
426 r1=r2
427 r2=r
428 t1=t2
429 t2=t
430 if t1>0:
431 return t1
432 else:
433 return t1%phi
434 else:
435 return -1
436
437def encrypt(s,e,n):
438 c=pow(s,e,n)
439 return c
440
441def decrypt(c,e,n):
442 p=pow(c,d,n)
443 return p
444
445print("RSA key generation:")
446print("1. Encryption with public key")
447print("2. Encryption with private key(Digital Signature)")
448ch=int(input("Enter your choice:"))
449
450n=int(input("Enter n:"))
451print("n:",n)
452
453#factorize(n)
454fact=factorint(n)
455factors=list(fact.keys())
456power=list(fact.values())
457print(factors)
458print(power)
459phi=calc_phi()
460
461d=-1
462while d==-1:
463 e=int(input("Enter e:"))
464 print("e:",e)
465 d=mul_inv(e,n)
466 if d==-1:
467 print("Multiplicative inverse doesn't exist. Try again.")
468print("d:",d)
469if ch==1:
470 print("Public Key: (", n, ",", e, ")")
471 print("Private Key: (", n, ",", d, ")")
472else:
473 print("Private Key: (", n, ",", e, ")")
474 print("Public Key: (", n, ",", d, ")")
475s=int(input("Enter the plain text:"))
476c=encrypt(s,e,n)
477print("encrypted text : ",c)
478p=decrypt(c,e,n)
479print("decrypted text : ",p)
480
481
482/////////////////////////////PRODUCT CIPHER .JAVA
483
484import java.io.*;
485import java.util.*;
486class ProductCipher
487{
488public static void main(String args[]) throws IOException
489{
490int itr=3;
491Scanner sc=new Scanner(System.in);
492System.out.println("Enter plain text:");
493String pt=sc.nextLine();
494pt=pt.toUpperCase();
495pt=pt.replaceAll("\\s", "");
496System.out.println("The plain text is: "+pt);
497System.out.println("Enter the key:");
498int key = sc.nextInt();
499System.out.println("Cipher Text generated using substitution technique is : ");
500char ct[] = pt.toCharArray();
501for(int x=0; x<itr; x++){
502for( int i=0;i<ct.length;i++)
503{
504ct[i] = (char)((key+(int)ct[i]-65)%26+65);
505}
506System.out.println("Substitution Cipher result after round "+(x+1)+":");
507for( int i=0;i<ct.length;i++)
508{
509System.out.print(ct[i]);
510}
511System.out.println();
512}
513System.out.println();
514System.out.println();
515System.out.println();
516String pt1 = new String(ct);
517System.out.println("Plaintext to Transformation Technique is :" + pt1);
518System.out.println("Enter the key:");
519int k= sc.nextInt();
520char a[] = pt1.toCharArray();
521int l,t;
522l=a.length;
523t=l;
524int m=0,i,j;
525if(l%k==0)
526l=l/k;
527else
528l=l/k+1;
529char b[][]=new char[l][k];
530for( i=0;i<l;i++)
531
532{ for( j=0;j<k;j++)
533{if(m==t)
534
535b[i][j]='#';
536else
537{ b[i][j]=a[m];
538m++;
539}
540}
541}
542System.out.println("Entered text in matrix form is : ");
543for(i=0;i<l;i++)
544{ for(j=0;j<k;j++)
545{ System.out.print(b[i][j]);
546}
547System.out.println();
548}
549System.out.println("Cipher Text is");
550String finalCipherText="";
551for(i=0;i<k;i++)
552{ for(j=0;j<l;j++)
553{
554finalCipherText+=(Character.toString(b[j][i]));
555//System.out.print(b[j][i]);
556}
557}
558System.out.println(finalCipherText);
559//Lets decrypt the text
560System.out.println("Starting to decrypt:");
561for(i=0;i<k;i++)
562{ for(j=0;j<l;j++)
563{ System.out.print(b[j][i]);
564}
565System.out.println();
566}
567String transpositionText="";
568for(i=0;i<l;i++)
569{ for(j=0;j<k;j++)
570{
571transpositionText+=(Character.toString(b[i][j]));
572//System.out.print(b[i][j]);
573}
574}
575int temp;
576char ct1[] = transpositionText.toCharArray();
577for(int x=0; x<itr; x++){
578for(i=0;i<ct1.length;i++)
579{
580temp=(int)ct1[i];
581
582ct1[i] = (char)((temp-key-65)%26+65);
583}
584System.out.println("Decryption Round "+(x+1)+":");
585for(i=0;i<ct.length;i++)
586{
587System.out.print(ct1[i]);
588}
589System.out.println();
590}
591System.out.println("Entered text was:");
592for(i=0;i<ct.length;i++)
593{
594System.out.print(ct1[i]);
595}
596}//End of main
597}//End of class
598
599
600////////////////////////////// hping
601sudo hping3 192.168.37.56
602sudo hping3 -c 10000 --flood --rand-source 192.168.37.56
603sudo hping3 -c 10 192.168.36.193
604sudo hping3 -c 10 -d 120 192.168.36.193
605sudo hping3 -1 -c 10 -a 192.168.36.193 192.168.37.56
606
607
608///////////////////////////COMMANDS
609
610ifconfig
611whois 192.168.39.187
612dig www.google.com OR dig google.com +short
613traceroute www.google.com
614dig 192.168.39.187
615Clear
616nslookup google.com
617sudo netstat -plnt
618netstat -r
619
620Find ves public ip address? -
621dig ves.ac.in
622
623
624OS version using nmap-
625$ sudo nmap -v -Pn -O 192.168.45.151
626
627
628--------------------------------------------------------------------------------------------------
629nmap google.com
630sudo nmap -O google.com
631sudo nmap -sX google.com
632sudo iptables -A INPUT -s 192.168.40.11 -j DROP
633sudo iptables -A INPUT -s 192.168.40.11 -j ACCEPT
634whois www.google.com
635dig www.google.com
636
637/////////////////////////CODE FOR BUFFER OVERFLOW
638#include<stdio.h>
639int main(){
640int arr[] = {47,58,32};
641printf("%d\n", arr[0]);
642printf("%d\n", arr[20]);
643return 0;
644}
645
646
647
648///////////////////////////////GPG
649
650GPG
651Installing GPG
652lab308-3@Shubham:~$ sudo apt-get update
653[sudo] password for lab308-3:
654Hit:1 http://ppa.launchpad.net/certbot/certbot/ubuntu xenial InRelease Hit:2 http://security.ubuntu.com/ubuntu xenial-security InRelease Hit:3 http://in.archive.ubuntu.com/ubuntu xenial InRelease
655Hit:4 http://ppa.launchpad.net/danielrichter2007/grub-customizer/ubuntu xenial InRelease Hit:5 http://in.archive.ubuntu.com/ubuntu xenial-updates InRelease
656Hit:6 http://in.archive.ubuntu.com/ubuntu xenial-backports InRelease Hit:7 http://ppa.launchpad.net/gns3/ppa/ubuntu xenial InRelease
657Hit:8 http://ppa.launchpad.net/otto-kesselgulasch/gimp/ubuntu xenial InRelease Reading package lists... Done
658lab308-3@Shubham:~$ sudo apt-get install gnupg
659Reading package lists... Done
660Building dependency tree
661Reading state information... Done
662gnupg is already the newest version (1.4.20-1ubuntu3.3).
6630 upgraded, 0 newly installed, 0 to remove and 141 not upgraded.
664lab308-3@Shubham:~$ gpg --gen-key
665gpg (GnuPG) 1.4.20; Copyright (C) 2015 Free Software Foundation, Inc.
666This is free software: you are free to change and redistribute it.
667There is NO WARRANTY, to the extent permitted by law.
668Key Generation
669
670
671lab308-3@Shubham:~$ gpg --gen-key
672
673gpg (GnuPG) 1.4.20; Copyright (C) 2015 Free Software Foundation, Inc.
674This is free software: you are free to change and redistribute it.
675There is NO WARRANTY, to the extent permitted by law.
676Please select what kind of key you want:
677(1) RSA and RSA (default)
678(2) DSA and Elgamal
679(3) DSA (sign only)
680(4) RSA (sign only)
681Your selection? 1
682RSA keys may be between 1024 and 4096 bits long.
683What keysize do you want? (2048) 4096
684Requested keysize is 4096 bits
685Please specify how long the key should be valid.
6860 = key does not expire
687<n> = key expires in n days
688<n>w = key expires in n weeks
689<n>m = key expires in n months
690<n>y = key expires in n years
691Key is valid for? (0) 1y
692Key expires at Tuesday 17 March 2020 08:41:50 AM IST
693Is this correct? (y/N) y
694You need a user ID to identify your key; the software constructs the user ID from the Real Name, Comment and Email Address in this form:
695"Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"
696Real name: Stephen Grinder
697Email address: 2016.stephen.grinder@ves.ac.in
698Comment: Stephen
699You selected this USER-ID:
700"Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>"
701Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
702You need a Passphrase to protect your secret key.
703We need to generate a lot of random bytes. It is a good idea to perform some other action (type on the keyboard, move the mouse, utilize the disks) during the prime generation; this gives the random number generator a better chance to gain enough entropy.
704Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy! (Need 203 more bytes)
705.........+++++
706Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy! (Need 11 more bytes)
707.........+++++
708We need to generate a lot of random bytes. It is a good idea to perform some other action (type on the keyboard, move the mouse, utilize the disks) during the prime generation; this gives the random number generator a better chance to gain enough entropy.
709Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy! (Need 178 more bytes) .+++++
710Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy! (Need 243 more bytes)
711.......+++++
712gpg: /home/lab308-3/.gnupg/trustdb.gpg: trustdb created
713gpg: key 7EDF0433 marked as ultimately trusted
714public and secret key created and signed.
715gpg: checking the trustdb
716gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
717gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
718gpg: next trustdb check due at 2020-03-17
719pub 4096R/7EDF0433 2019-03-18 [expires: 2020-03-17]
720Key fingerprint = 8A72 FEAC 9855 2574 4ED5 0A91 D06F 2B3F 7EDF 0433
721uid Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>
722sub 4096R/8D3D2327 2019-03-18 [expires: 2020-03-17]
723Create a Revocation Certificate
724lab308-3@Shubham:~$ gpg --output ~/revocation.crt --gen-revoke 2016.stephen.grinder@ves.ac.in
725sec 4096R/7EDF0433 2019-03-18 Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>
726Create a revocation certificate for this key? (y/N) y
727Please select the reason for the revocation:
7280 = No reason specified
7291 = Key has been compromised
7302 = Key is superseded
7313 = Key is no longer used
732Q = Cancel
733(Probably you want to select 1 here)
734Your decision? 0
735Enter an optional description; end it with an empty line:
736>
737Reason for revocation: No reason specified
738(No description given)
739Is this okay? (y/N) y
740You need a passphrase to unlock the secret key for
741user: "Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>"
7424096-bit RSA key, ID 7EDF0433, created 2019-03-18
743ASCII armored output forced.
744Revocation certificate created.
745Please move it to a medium which you can hide away; if Mallory gets access to this certificate he can use it to make your key unusable. It is smart to print this certificate and store it away, just in case
746your media become unreadable. But have some caution: The print system of your machine might store the data and make it available to others!
747lab308-3@Shubham:~$ chmod 600 ~/revocation.crt
748Listing all generated keys
749stephen@stephen:~$ gpg --
750list-secret-keys
751/home/stephen/.gnupg/secring.gpg
752-----------------------------
753sec 2048R/84C7D581 2019-03-31 [expires: 2020-03-30]
754uid Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>
755ssb 2048R/46ECE634 2019-03-31
756Send your public key as a file to the recipient
757stephen@stephen:~$ gpg -- armor --output mypubkey.gpg export 2016.stephen.grinder@ves.ac.in--
758stephen@stephen:~$ gpg mypubkey.gpg
759pub 2048R/84C7D581 2019-03-31 Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in> sub 2048R/46ECE634 2019-03-31 [expires: 2020-03-30]
760Friend sends his/her public key to you
761stephen@stephen:~$ gpg --import mypubkey.gpg
762gpg: key 84C7D581: "Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>" not changed
763gpg: Total number processed: 1
764gpg: unchanged: 1
765
766
767Encryption
768
769stephen@stephen:~$ gpg --encrypt --sign --armor -r 2016.stephen.grinder@ves.ac.in abc.txt You need a passphrase to unlock the secret key for
770user: "Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>"
7712048-bit RSA key, ID 84C7D581, created 2019-03-31
772Decryption
773
774
775stephen@stephen:~$ gpg abc.txt.asc
776You need a passphrase to unlock the secret key for
777user: "Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>"
7782048-bit RSA key, ID 46ECE634, created 2019-03-31 (main key ID 84C7D581)
779gpg: encrypted with 2048-bit RSA key, ID 46ECE634, created 2019-03-31 "Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>"
780File `abc.txt' exists. Overwrite? (y/N) y
781gpg: Signature made Sunday 31 March 2019 07:52:23 PM IST using RSA key ID 84C7D581
782gpg: Good signature from "Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>"
783
784
785//////////////////////////////SQLMAP
786
787SQLMAP -U SITENAME -D ACUART -TABLES
788http://testphp.vulnweb.com/listproducts.php?cat=*
789sqlmap -u http://testphp.vulnweb.com/listproducts.php?cat=* --dbs
790
791
792
793Sladyn
794
795
796TO get all info about a website
797sqlmap -u http://testphp.vulnweb.com/listproducts.php?cat=1 --dbs
798
799to get info about a particular table
800sqlmap -u http://testphp.vulnweb.com/listproducts.php?cat=1 -D acuart --tables
801
802to list data in a specific column
803sqlmap -u http://testphp.vulnweb.com/listproducts.php?cat=1 -D acuart -T artists --columns
804
805infot in a column
806sqlmap -u http://testphp.vulnweb.com/listproducts.php?cat=1 -D acuart -T artists -C aname --dump
807
808
809/////////////////////MD5 Number 5
810import hashlib
811import time
812import os
813import math
814md=open("hii.txt","r")
815data=md.read()
816print('Length of input data is :',len(data))
817start = time.clock()
818result = hashlib.md5(data.encode())
819print(result.hexdigest())
820a=len(result.hexdigest())
821end = time.clock()
822print('length of encoded data using md5',a)
823print("time required :",end-start)
824
825///////////////////SHA
826import hashlib
827import time
828# initializing string
829str1 = "Hi"
830input_length=len(str1)
831start_time=time.time()
832# then sending to SHA1()
833result = hashlib.sha1(str1.encode())
834print("The hexadecimal equivalent of SHA1 is : ")
835print(result.hexdigest())
836end_time=time.time()
837print('length of input string',input_length)
838print('length of output string',result.digest_size)
839print('Start time =',start_time)
840print('End_time=',end_time)
841print('Total time required =',(end_time-start_time))