mirror of
https://github.com/autistic-symposium/sec-pentesting-toolkit.git
synced 2025-05-02 06:46:07 -04:00
some small fixes
This commit is contained in:
parent
ab70b811db
commit
a50737bc6b
63 changed files with 8 additions and 19 deletions
27
CTFs_and_WarGames/WARGAMES/krypton/freq_count.py
Normal file
27
CTFs_and_WarGames/WARGAMES/krypton/freq_count.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/python
|
||||
|
||||
import string
|
||||
import sys
|
||||
import operator
|
||||
|
||||
def find_frequency(msg):
|
||||
dict_freq = dict([(c, 0) for c in string.lowercase])
|
||||
total_letters = 0.0
|
||||
for c in msg.lower():
|
||||
if 'a'<= c <= 'z':
|
||||
dict_freq[c] += 1
|
||||
total_letters += 1
|
||||
list_freq = sorted(dict_freq.items(), key=operator.itemgetter(1))
|
||||
return list_freq
|
||||
|
||||
|
||||
|
||||
def main(filename):
|
||||
with open(filename, 'r') as f:
|
||||
cipher = f.readlines()
|
||||
cipher = cipher[0].strip()
|
||||
print(find_frequency(cipher))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(str(sys.argv[1]))
|
Loading…
Add table
Add a link
Reference in a new issue