Advertisement
Guest User

css-jugad

a guest
Apr 29th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.09 KB | None | 0 0
  1. Programs:
  2. ///////////////////////////////Caesar Cipher:
  3.  
  4. # encrypt and decrypt a text using a simple algorithm of offsetting the letters
  5.  
  6. key = 'abcdefghijklmnopqrstuvwxyz'
  7.  
  8. def 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.  
  21. def 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.  
  34. text = "I am coding Python on SoloLearn!"
  35. offset = 5
  36.  
  37. encrypted = encrypt(offset, text)
  38. print('Encrypted:', encrypted)
  39.  
  40. decrypted = decrypt(offset, encrypted)
  41. print('Decrypted:', decrypted)
  42.  
  43.  
  44. ////////////////////////////Transposition Cipher
  45. // CPP program for illustrating
  46. // Columnar Transposition Cipher
  47. #include<bits/stdc++.h>
  48. using namespace std;
  49.  
  50. // Key for Columnar Transposition
  51. string const key = "HACK";
  52. map<int,int> keyMap;
  53.  
  54. void 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
  64. string 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
  117. string 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
  163. int 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.  
  183. import math
  184. import random
  185.  
  186. def 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.  
  199. def 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.  
  209. if __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 '''
  223. import math
  224.  
  225. #WORKING
  226. ''' e.g. message is 'Python' to be transposed
  227. In keyless trans.n message is split into 2 rows having alternate characters of message
  228. 1st row --> | P | | T | | O | |
  229. 2nd row --> | | Y | | H | | N |
  230. The transposed message will be all characters of 1st row then of the 2nd row
  231. i.e. --> 'PTOYHN'
  232. '''
  233.  
  234. def 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.  
  248. def 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.  
  261. if __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
  274. iptables -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
  282. iptables -A OUTPUT -p tcp -m string --string "sitename.com" --algo kmp -j REJECT
  283. ***********unblock websites
  284. iptables -D OUTPUT -p tcp -m string --string "sitename.com" --algo kmp -j REJECT
  285.  
  286. ////////////////////////////DEFFI HELLMAN
  287. ******************server.py
  288. import random
  289. import socket
  290.  
  291. def 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.  
  307. def 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.  
  316. if __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
  332. import random
  333. import socket
  334.  
  335. def 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.  
  351. def 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.  
  361. if __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.  
  378. import math
  379. from sympy import factorint #pip install sympy
  380.  
  381. factors=[]
  382. power=[]
  383. '''
  384. def isPrime(p):
  385. for i in range(2,p//2+1):
  386. if p%i==0:
  387. return False
  388. return True
  389.  
  390. def 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. '''
  406. def 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.  
  415. def 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.  
  437. def encrypt(s,e,n):
  438. c=pow(s,e,n)
  439. return c
  440.  
  441. def decrypt(c,e,n):
  442. p=pow(c,d,n)
  443. return p
  444.  
  445. print("RSA key generation:")
  446. print("1. Encryption with public key")
  447. print("2. Encryption with private key(Digital Signature)")
  448. ch=int(input("Enter your choice:"))
  449.  
  450. n=int(input("Enter n:"))
  451. print("n:",n)
  452.  
  453. #factorize(n)
  454. fact=factorint(n)
  455. factors=list(fact.keys())
  456. power=list(fact.values())
  457. print(factors)
  458. print(power)
  459. phi=calc_phi()
  460.  
  461. d=-1
  462. while 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.")
  468. print("d:",d)
  469. if ch==1:
  470. print("Public Key: (", n, ",", e, ")")
  471. print("Private Key: (", n, ",", d, ")")
  472. else:
  473. print("Private Key: (", n, ",", e, ")")
  474. print("Public Key: (", n, ",", d, ")")
  475. s=int(input("Enter the plain text:"))
  476. c=encrypt(s,e,n)
  477. print("encrypted text : ",c)
  478. p=decrypt(c,e,n)
  479. print("decrypted text : ",p)
  480.  
  481.  
  482. /////////////////////////////PRODUCT CIPHER .JAVA
  483.  
  484. import java.io.*;
  485. import java.util.*;
  486. class ProductCipher
  487. {
  488. public static void main(String args[]) throws IOException
  489. {
  490. int itr=3;
  491. Scanner sc=new Scanner(System.in);
  492. System.out.println("Enter plain text:");
  493. String pt=sc.nextLine();
  494. pt=pt.toUpperCase();
  495. pt=pt.replaceAll("\\s", "");
  496. System.out.println("The plain text is: "+pt);
  497. System.out.println("Enter the key:");
  498. int key = sc.nextInt();
  499. System.out.println("Cipher Text generated using substitution technique is : ");
  500. char ct[] = pt.toCharArray();
  501. for(int x=0; x<itr; x++){
  502. for( int i=0;i<ct.length;i++)
  503. {
  504. ct[i] = (char)((key+(int)ct[i]-65)%26+65);
  505. }
  506. System.out.println("Substitution Cipher result after round "+(x+1)+":");
  507. for( int i=0;i<ct.length;i++)
  508. {
  509. System.out.print(ct[i]);
  510. }
  511. System.out.println();
  512. }
  513. System.out.println();
  514. System.out.println();
  515. System.out.println();
  516. String pt1 = new String(ct);
  517. System.out.println("Plaintext to Transformation Technique is :" + pt1);
  518. System.out.println("Enter the key:");
  519. int k= sc.nextInt();
  520. char a[] = pt1.toCharArray();
  521. int l,t;
  522. l=a.length;
  523. t=l;
  524. int m=0,i,j;
  525. if(l%k==0)
  526. l=l/k;
  527. else
  528. l=l/k+1;
  529. char b[][]=new char[l][k];
  530. for( i=0;i<l;i++)
  531.  
  532. { for( j=0;j<k;j++)
  533. {if(m==t)
  534.  
  535. b[i][j]='#';
  536. else
  537. { b[i][j]=a[m];
  538. m++;
  539. }
  540. }
  541. }
  542. System.out.println("Entered text in matrix form is : ");
  543. for(i=0;i<l;i++)
  544. { for(j=0;j<k;j++)
  545. { System.out.print(b[i][j]);
  546. }
  547. System.out.println();
  548. }
  549. System.out.println("Cipher Text is");
  550. String finalCipherText="";
  551. for(i=0;i<k;i++)
  552. { for(j=0;j<l;j++)
  553. {
  554. finalCipherText+=(Character.toString(b[j][i]));
  555. //System.out.print(b[j][i]);
  556. }
  557. }
  558. System.out.println(finalCipherText);
  559. //Lets decrypt the text
  560. System.out.println("Starting to decrypt:");
  561. for(i=0;i<k;i++)
  562. { for(j=0;j<l;j++)
  563. { System.out.print(b[j][i]);
  564. }
  565. System.out.println();
  566. }
  567. String transpositionText="";
  568. for(i=0;i<l;i++)
  569. { for(j=0;j<k;j++)
  570. {
  571. transpositionText+=(Character.toString(b[i][j]));
  572. //System.out.print(b[i][j]);
  573. }
  574. }
  575. int temp;
  576. char ct1[] = transpositionText.toCharArray();
  577. for(int x=0; x<itr; x++){
  578. for(i=0;i<ct1.length;i++)
  579. {
  580. temp=(int)ct1[i];
  581.  
  582. ct1[i] = (char)((temp-key-65)%26+65);
  583. }
  584. System.out.println("Decryption Round "+(x+1)+":");
  585. for(i=0;i<ct.length;i++)
  586. {
  587. System.out.print(ct1[i]);
  588. }
  589. System.out.println();
  590. }
  591. System.out.println("Entered text was:");
  592. for(i=0;i<ct.length;i++)
  593. {
  594. System.out.print(ct1[i]);
  595. }
  596. }//End of main
  597. }//End of class
  598.  
  599.  
  600. ////////////////////////////// hping
  601. sudo hping3 192.168.37.56
  602. sudo hping3 -c 10000 --flood --rand-source 192.168.37.56
  603. sudo hping3 -c 10 192.168.36.193
  604. sudo hping3 -c 10 -d 120 192.168.36.193
  605. sudo hping3 -1 -c 10 -a 192.168.36.193 192.168.37.56
  606.  
  607.  
  608. ///////////////////////////COMMANDS
  609.  
  610. ifconfig
  611. whois 192.168.39.187
  612. dig www.google.com OR dig google.com +short
  613. traceroute www.google.com
  614. dig 192.168.39.187
  615. Clear
  616. nslookup google.com
  617. sudo netstat -plnt
  618. netstat -r
  619.  
  620. Find ves public ip address? -
  621. dig ves.ac.in
  622.  
  623.  
  624. OS version using nmap-
  625. $ sudo nmap -v -Pn -O 192.168.45.151
  626.  
  627.  
  628. --------------------------------------------------------------------------------------------------
  629. nmap google.com
  630. sudo nmap -O google.com
  631. sudo nmap -sX google.com
  632. sudo iptables -A INPUT -s 192.168.40.11 -j DROP
  633. sudo iptables -A INPUT -s 192.168.40.11 -j ACCEPT
  634. whois www.google.com
  635. dig www.google.com
  636.  
  637. /////////////////////////CODE FOR BUFFER OVERFLOW
  638. #include<stdio.h>
  639. int main(){
  640. int arr[] = {47,58,32};
  641. printf("%d\n", arr[0]);
  642. printf("%d\n", arr[20]);
  643. return 0;
  644. }
  645.  
  646.  
  647.  
  648. ///////////////////////////////GPG
  649.  
  650. GPG
  651. Installing GPG
  652. lab308-3@Shubham:~$ sudo apt-get update
  653. [sudo] password for lab308-3:
  654. Hit: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
  655. Hit:4 http://ppa.launchpad.net/danielrichter2007/grub-customizer/ubuntu xenial InRelease Hit:5 http://in.archive.ubuntu.com/ubuntu xenial-updates InRelease
  656. Hit:6 http://in.archive.ubuntu.com/ubuntu xenial-backports InRelease Hit:7 http://ppa.launchpad.net/gns3/ppa/ubuntu xenial InRelease
  657. Hit:8 http://ppa.launchpad.net/otto-kesselgulasch/gimp/ubuntu xenial InRelease Reading package lists... Done
  658. lab308-3@Shubham:~$ sudo apt-get install gnupg
  659. Reading package lists... Done
  660. Building dependency tree
  661. Reading state information... Done
  662. gnupg is already the newest version (1.4.20-1ubuntu3.3).
  663. 0 upgraded, 0 newly installed, 0 to remove and 141 not upgraded.
  664. lab308-3@Shubham:~$ gpg --gen-key
  665. gpg (GnuPG) 1.4.20; Copyright (C) 2015 Free Software Foundation, Inc.
  666. This is free software: you are free to change and redistribute it.
  667. There is NO WARRANTY, to the extent permitted by law.
  668. Key Generation
  669.  
  670.  
  671. lab308-3@Shubham:~$ gpg --gen-key
  672.  
  673. gpg (GnuPG) 1.4.20; Copyright (C) 2015 Free Software Foundation, Inc.
  674. This is free software: you are free to change and redistribute it.
  675. There is NO WARRANTY, to the extent permitted by law.
  676. Please 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)
  681. Your selection? 1
  682. RSA keys may be between 1024 and 4096 bits long.
  683. What keysize do you want? (2048) 4096
  684. Requested keysize is 4096 bits
  685. Please specify how long the key should be valid.
  686. 0 = 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
  691. Key is valid for? (0) 1y
  692. Key expires at Tuesday 17 March 2020 08:41:50 AM IST
  693. Is this correct? (y/N) y
  694. You 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>"
  696. Real name: Stephen Grinder
  697. Email address: 2016.stephen.grinder@ves.ac.in
  698. Comment: Stephen
  699. You selected this USER-ID:
  700. "Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>"
  701. Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
  702. You need a Passphrase to protect your secret key.
  703. We 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.
  704. Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy! (Need 203 more bytes)
  705. .........+++++
  706. Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy! (Need 11 more bytes)
  707. .........+++++
  708. We 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.
  709. Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy! (Need 178 more bytes) .+++++
  710. Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy! (Need 243 more bytes)
  711. .......+++++
  712. gpg: /home/lab308-3/.gnupg/trustdb.gpg: trustdb created
  713. gpg: key 7EDF0433 marked as ultimately trusted
  714. public and secret key created and signed.
  715. gpg: checking the trustdb
  716. gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
  717. gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
  718. gpg: next trustdb check due at 2020-03-17
  719. pub 4096R/7EDF0433 2019-03-18 [expires: 2020-03-17]
  720. Key fingerprint = 8A72 FEAC 9855 2574 4ED5 0A91 D06F 2B3F 7EDF 0433
  721. uid Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>
  722. sub 4096R/8D3D2327 2019-03-18 [expires: 2020-03-17]
  723. Create a Revocation Certificate
  724. lab308-3@Shubham:~$ gpg --output ~/revocation.crt --gen-revoke 2016.stephen.grinder@ves.ac.in
  725. sec 4096R/7EDF0433 2019-03-18 Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>
  726. Create a revocation certificate for this key? (y/N) y
  727. Please select the reason for the revocation:
  728. 0 = No reason specified
  729. 1 = Key has been compromised
  730. 2 = Key is superseded
  731. 3 = Key is no longer used
  732. Q = Cancel
  733. (Probably you want to select 1 here)
  734. Your decision? 0
  735. Enter an optional description; end it with an empty line:
  736. >
  737. Reason for revocation: No reason specified
  738. (No description given)
  739. Is this okay? (y/N) y
  740. You need a passphrase to unlock the secret key for
  741. user: "Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>"
  742. 4096-bit RSA key, ID 7EDF0433, created 2019-03-18
  743. ASCII armored output forced.
  744. Revocation certificate created.
  745. Please 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
  746. your media become unreadable. But have some caution: The print system of your machine might store the data and make it available to others!
  747. lab308-3@Shubham:~$ chmod 600 ~/revocation.crt
  748. Listing all generated keys
  749. stephen@stephen:~$ gpg --
  750. list-secret-keys
  751. /home/stephen/.gnupg/secring.gpg
  752. -----------------------------
  753. sec 2048R/84C7D581 2019-03-31 [expires: 2020-03-30]
  754. uid Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>
  755. ssb 2048R/46ECE634 2019-03-31
  756. Send your public key as a file to the recipient
  757. stephen@stephen:~$ gpg -- armor --output mypubkey.gpg export 2016.stephen.grinder@ves.ac.in--
  758. stephen@stephen:~$ gpg mypubkey.gpg
  759. pub 2048R/84C7D581 2019-03-31 Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in> sub 2048R/46ECE634 2019-03-31 [expires: 2020-03-30]
  760. Friend sends his/her public key to you
  761. stephen@stephen:~$ gpg --import mypubkey.gpg
  762. gpg: key 84C7D581: "Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>" not changed
  763. gpg: Total number processed: 1
  764. gpg: unchanged: 1
  765.  
  766.  
  767. Encryption
  768.  
  769. stephen@stephen:~$ gpg --encrypt --sign --armor -r 2016.stephen.grinder@ves.ac.in abc.txt You need a passphrase to unlock the secret key for
  770. user: "Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>"
  771. 2048-bit RSA key, ID 84C7D581, created 2019-03-31
  772. Decryption
  773.  
  774.  
  775. stephen@stephen:~$ gpg abc.txt.asc
  776. You need a passphrase to unlock the secret key for
  777. user: "Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>"
  778. 2048-bit RSA key, ID 46ECE634, created 2019-03-31 (main key ID 84C7D581)
  779. gpg: encrypted with 2048-bit RSA key, ID 46ECE634, created 2019-03-31 "Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>"
  780. File `abc.txt' exists. Overwrite? (y/N) y
  781. gpg: Signature made Sunday 31 March 2019 07:52:23 PM IST using RSA key ID 84C7D581
  782. gpg: Good signature from "Stephen Grinder (Stephen) <2016.stephen.grinder@ves.ac.in>"
  783.  
  784.  
  785. //////////////////////////////SQLMAP
  786.  
  787. SQLMAP -U SITENAME -D ACUART -TABLES
  788. http://testphp.vulnweb.com/listproducts.php?cat=*
  789. sqlmap -u http://testphp.vulnweb.com/listproducts.php?cat=* --dbs
  790.  
  791.  
  792.  
  793. Sladyn
  794.  
  795.  
  796. TO get all info about a website
  797. sqlmap -u http://testphp.vulnweb.com/listproducts.php?cat=1 --dbs
  798.  
  799. to get info about a particular table
  800. sqlmap -u http://testphp.vulnweb.com/listproducts.php?cat=1 -D acuart --tables
  801.  
  802. to list data in a specific column
  803. sqlmap -u http://testphp.vulnweb.com/listproducts.php?cat=1 -D acuart -T artists --columns
  804.  
  805. infot in a column
  806. sqlmap -u http://testphp.vulnweb.com/listproducts.php?cat=1 -D acuart -T artists -C aname --dump
  807.  
  808.  
  809. /////////////////////MD5 Number 5
  810. import hashlib
  811. import time
  812. import os
  813. import math
  814. md=open("hii.txt","r")
  815. data=md.read()
  816. print('Length of input data is :',len(data))
  817. start = time.clock()
  818. result = hashlib.md5(data.encode())
  819. print(result.hexdigest())
  820. a=len(result.hexdigest())
  821. end = time.clock()
  822. print('length of encoded data using md5',a)
  823. print("time required :",end-start)
  824.  
  825. ///////////////////SHA
  826. import hashlib
  827. import time
  828. # initializing string
  829. str1 = "Hi"
  830. input_length=len(str1)
  831. start_time=time.time()
  832. # then sending to SHA1()
  833. result = hashlib.sha1(str1.encode())
  834. print("The hexadecimal equivalent of SHA1 is : ")
  835. print(result.hexdigest())
  836. end_time=time.time()
  837. print('length of input string',input_length)
  838. print('length of output string',result.digest_size)
  839. print('Start time =',start_time)
  840. print('End_time=',end_time)
  841. print('Total time required =',(end_time-start_time))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement