Cheat sheet

सारे commands, एक जगह

Yahan har wo command hai jo abhi tak ke lessons mein aayi — purpose, parameters, expected output, aam error, safe usage aur security implication ke saath. Ratna mat; samajh kar use karo.

01Lesson commands

lscpu

Y01-P01-D01-M01-C01-T01-L01 · CPU असल में करता क्या है?

Purpose

CPU का architecture, core, cache और features print करता है।

Syntax

lscpu [options]

Parameters

  • -eSummary की जगह हर CPU की अलग table दिखाता है।

Expected output

Architecture, op-mode, byte order, core/socket count, model name, cache size, और एक लंबी Flags line।

आम error

macOS पे नहीं है — वहाँ `sysctl -n machdep.cpu.brand_string` use करो।

Safe usage

सिर्फ़ पढ़ता है, कुछ बदलता नहीं। हर machine पे safe है।

Security implication

Flags line बताती है कि hardware में कौन से security features हैं: `nx` (non-executable pages), `smep`/`smap` (kernel-user separation), `pti` (Meltdown mitigation)। Level 41 पे आप इसी output से decide करोगे कि target पे कौन सी mitigation लगी हुई है।
objdump -d ./add

Y01-P01-D01-M01-C01-T01-L01 · CPU असल में करता क्या है?

Purpose

Compiled binary को वापस assembly (पढ़ने लायक़ form) में तोड़ता है।

Syntax

objdump -d [-M intel] <binary>

Parameters

  • -dसिर्फ़ executable हिस्सों को disassemble करो।
  • -M intelIntel syntax — शुरुआत में AT&T से आसान लगता है।

Expected output

हर instruction का address, raw bytes और नाम, function के हिसाब से grouped।

आम error

'File format not recognized' — आपने binary की जगह source code (.c file) दे दिया।

Safe usage

ये binary को CHALATA NAHI, सिर्फ़ पढ़ता है। इसी वजह से अनजान file पे ये हमेशा पहला safe step होता है।

Security implication

यहीं से reverse engineering (Domain 21) शुरू होती है। बिना चलाए analysis करना सबसे सुरक्षित तरीक़ा है।
gdb ./add

Y01-P01-D01-M01-C01-T01-L01 · CPU असल में करता क्या है?

Purpose

Program को debugger के अंदर चलाता है ताकि आप उसे रोक कर CPU और memory की हालत देख सको।

Syntax

gdb <binary>, फिर `break main`, `run`, `si`, `info registers`

Parameters

  • siएक machine instruction आगे बढ़ो — मतलब fetch-decode-execute का एक चक्कर।
  • info registersसारे register दिखाओ, RIP के साथ।

Expected output

एक prompt, और हर `si` के बाद बदलते हुए register values।

आम error

'ptrace: Operation not permitted' — kernel hardening। ऊपर troubleshooting देखो।

Safe usage

सिर्फ़ अपने बनाए programs debug करो। अनजान या malware file KABHI भी normal machine पे debug मत करो — उसके लिए Domain 18 का isolated setup है।

Security implication

Debugger के पास process पे पूरा control होता है — memory पढ़ सकता है, लिख सकता है, execution बदल सकता है। इसलिए debugging की permission ख़ुद एक security boundary है।
free -h

Y01-P01-D01-M01-C01-T02-L01 · Memory: RAM, Cache, और 'volatile' होने का मतलब

Purpose

Total, used, free, buffer/cache और available memory दिखाता है, पढ़ने लायक़ units में।

Syntax

free [-h] [-s <seconds>]

Parameters

  • -hHuman-readable (GB/MB)।
  • -s 2हर 2 second repeat — memory leak देखने के लिए बहुत काम का।

Expected output

दो rows (Mem और Swap) और columns: total, used, free, shared, buff/cache, available।

आम error

'free' कम देख कर घबरा जाना। Linux जान-बूझ कर ख़ाली RAM को cache बनाता है। असली number 'available' है।

Safe usage

सिर्फ़ पढ़ता है।

Security implication

Swap row में non-zero value का मतलब है कि memory का content disk पे लिखा जा चुका हो सकता है — सीधे इस सवाल से जुड़ा है कि 'क्या secret कभी disk पे गया?'
cat /proc/self/maps

Y01-P01-D01-M01-C01-T02-L01 · Memory: RAM, Cache, और 'volatile' होने का मतलब

Purpose

Current process का पूरा virtual memory map: हर region, उसकी permission, और उसकी backing file।

Syntax

cat /proc/<pid>/maps

Parameters

  • <pid>`self` = जो process पढ़ रहा है, या अपना कोई PID।

Expected output

Lines ऐसे: `address-range perms offset dev inode pathname`, जैसे `7f...-7f... r-xp ... /usr/lib/libc.so.6`

आम error

दूसरे user के process पे permission denied — ये सही और expected है।

Safe usage

सिर्फ़ अपने process। दूसरों के process सिर्फ़ तब जब आप अपनी ही machine पे root हो।

Security implication

ये file process का layout खोल देती है। इसका readable होना ख़ुद एक security consideration है — और जो randomness आप addresses में देख रहे हो वो ASLR है जो layout को predict होने से रोकता है।
grep -E 'Vm(Size|RSS|Swap)' /proc/<pid>/status

Y01-P01-D01-M01-C01-T02-L01 · Memory: RAM, Cache, और 'volatile' होने का मतलब

Purpose

Process का virtual size, असली RAM usage और swap में गया हुआ हिस्सा compare करता है।

Syntax

grep -E 'Vm(Size|RSS|Swap)' /proc/<pid>/status

Expected output

3 lines, values kB में।

आम error

ख़ाली output — ग़लत PID, या process ख़त्म हो चुका।

Safe usage

सिर्फ़ पढ़ता है।

Security implication

VmSwap अगर zero नहीं है, तो इसका मतलब इस process की कुछ memory — जिसमें secrets भी हो सकते हैं — disk पे लिखी जा चुकी है।
lsblk -f

Y01-P01-D01-M01-C02-T01-L01 · Storage और Filesystem: 'delete' किया हुआ data जाता कहाँ है?

Purpose

सारे block devices, उनके filesystem, label और mount point दिखाता है।

Syntax

lsblk [-f] [-o COLUMNS]

Parameters

  • -fFilesystem type, label और UUID भी दिखाओ।

Expected output

Disks और partitions का tree, FSTYPE और MOUNTPOINT columns के साथ।

आम error

Loop device को असली disk समझ लेना। NAME column हमेशा ध्यान से पढ़ो।

Safe usage

सिर्फ़ पढ़ता है, safe है।

Security implication

कौन सा device कौन सा है — ये पता होना ही वो control है जो आपको ग़लत command से data बर्बाद करने से बचाता है। ये आदत किसी भी tool से ज़्यादा important है।
grep -a 'STRING' /path/to/image

Y01-P01-D01-M01-C02-T01-L01 · Storage और Filesystem: 'delete' किया हुआ data जाता कहाँ है?

Purpose

Raw disk image में एक byte sequence ढूँढता है, उसे text मान कर।

Syntax

grep -a [-b] 'pattern' <file>

Parameters

  • -aBinary file को text की तरह process करो।
  • -bहर match का byte offset print करो — file carving यहीं से शुरू होती है।

Expected output

Matching content, या कुछ नहीं अगर मिला नहीं।

आम error

`-a` भूल जाना और सिर्फ़ 'binary file matches' देखना।

Safe usage

सिर्फ़ अपनी images पे, read-only।

Security implication

ये सबसे simple file carving है — और Domain 16 की recovery का basic concept।
sync

Y01-P01-D01-M01-C02-T01-L01 · Storage और Filesystem: 'delete' किया हुआ data जाता कहाँ है?

Purpose

Kernel के page cache का data actual device पे लिखवाता है।

Syntax

sync

Expected output

कोई output नहीं; जब writes commit हो जाएँ तब वापस आता है।

आम error

sync किए बिना image देखना और ये समझ लेना कि data लिखा ही नहीं गया।

Safe usage

Safe।

Security implication

'Application ने लिख दिया' और 'media पे पहुँच गया' के बीच का gap ही वो जगह है जहाँ crash-consistency bugs और forensic surprises मिलते हैं।
systemd-analyze critical-chain

Y01-P01-D01-M01-C03-T01-L01 · Boot Process — एक 'Chain of Trust' की तरह

Purpose

वो dependency chain दिखाता है जिसने boot का time decide किया, हर unit के time के साथ।

Syntax

systemd-analyze critical-chain [UNIT]

Expected output

Units का tree, @ (start time) और + (duration) के साथ।

आम error

'Bootup is not yet finished' — कोई unit अभी भी start हो रहा है या अटका है।

Safe usage

सिर्फ़ पढ़ता है।

Security implication

Boot chain में अनजान units एक persistence indicator होते हैं। अपना NORMAL boot chain पता होना ही वो चीज़ है जो abnormal को दिखाता है।
journalctl -b -k

Y01-P01-D01-M01-C03-T01-L01 · Boot Process — एक 'Chain of Trust' की तरह

Purpose

Current boot के kernel messages दिखाता है।

Syntax

journalctl -b [-k] [-p err]

Parameters

  • -bसिर्फ़ current boot। `-b -1` = पिछला boot।
  • -kसिर्फ़ kernel messages।
  • -p errसिर्फ़ errors और उससे ऊपर।

Expected output

Timestamped kernel log lines, kernel version banner से शुरू।

आम error

ख़ाली output क्योंकि journal reboot के बाद save नहीं होता।

Safe usage

सिर्फ़ पढ़ता है।

Security implication

Early kernel logs में hardware, drivers और kernel command line होती है — जिसमें वो parameters भी हो सकते हैं जो security features BAND करते हैं।
cat /proc/cmdline

Y01-P01-D01-M01-C03-T01-L01 · Boot Process — एक 'Chain of Trust' की तरह

Purpose

वो exact parameters दिखाता है जो bootloader ने चलते हुए kernel को दिए।

Syntax

cat /proc/cmdline

Expected output

एक line, जैसे `BOOT_IMAGE=/vmlinuz root=UUID=... ro quiet splash`

आम error

ये मान लेना कि ये bootloader की config file से match करेगा — ये वो दिखाता है जो ASLI में boot हुआ।

Safe usage

सिर्फ़ पढ़ता है।

Security implication

यहाँ के parameters बड़ी protections बंद कर सकते हैं (जैसे `nokaslr`, या mitigation opt-outs)। किसी अनजान host पे ये line सबसे पहले पढ़ने लायक़ चीज़ों में है।
ldd ./binary

Y01-P01-D01-M02-C01-T01-L01 · File से Process तक: Virtual Address Space

Purpose

बताता है कि dynamically linked binary को कौन सी shared libraries चाहिए।

Syntax

ldd <binary>

Expected output

Library names, resolved paths और load addresses। या 'not a dynamic executable'।

आम error

अनजान binary पे ldd चलाना — कुछ systems पे loader उस file का code चला भी सकता है।

Safe usage

Untrusted file के लिए `readelf -d <binary> | grep NEEDED` बेहतर है: वो सिर्फ़ parse करता है, load नहीं करता।

Security implication

Dependency list ही binary का असली attack surface है, और Domain 27 की software composition analysis का base।
readelf -l ./binary

Y01-P01-D01-M02-C01-T01-L01 · File से Process तक: Virtual Address Space

Purpose

Program headers दिखाता है: वो segments जो kernel map करेगा, उनके permission flags के साथ।

Syntax

readelf -l <binary>

Parameters

  • -lProgram headers (load-time view)।
  • -SSection headers (link-time view)।

Expected output

LOAD entries R/E और RW flags के साथ, plus PT_INTERP जिसमें dynamic linker का नाम है।

आम error

Sections और segments को mix करना। Sections linking के लिए हैं; segments वो हैं जो ASLI में map होते हैं।

Safe usage

सिर्फ़ static parsing — untrusted files पे भी safe।

Security implication

Segment flags बताते हैं कि protections लगी हैं या नहीं — जैसे non-executable stack (GNU_STACK RW हो, RWE नहीं) और RELRO।
strace -e trace=openat,mmap ./binary

Y01-P01-D01-M02-C01-T01-L01 · File से Process तक: Virtual Address Space

Purpose

सिर्फ़ वो syscalls trace करता है जो libraries ढूँढने और map करने में लगते हैं।

Syntax

strace [-f] [-e trace=<set>] <command>

Parameters

  • -fFork की हुई child processes भी follow करो।
  • -e trace=सिर्फ़ चुने हुए syscalls — output पढ़ने लायक़ रखने के लिए ज़रूरी।

Expected output

openat calls जो library paths में ढूँढ रहे हैं, फिर mmap calls जो उन्हें map कर रहे हैं।

आम error

'ptrace: Operation not permitted' — वही kernel hardening जो Lesson 1 में मिला था।

Safe usage

सिर्फ़ अपने programs trace करो। Malware trace करने के लिए Domain 18 का isolated environment चाहिए।

Security implication

Syscall tracing behavioural analysis की बुनियाद है, और seccomp policy बनाने का पहला step भी।
strace -c <command>

Y01-P01-D01-M02-C03-T01-L01 · Privilege Boundary: User Mode, Kernel Mode और Syscall

Purpose

Command चलाता है और summary देता है कि कौन से syscalls, कितनी बार, और कितना time।

Syntax

strace -c [-f] <command>

Parameters

  • -cहर call की line नहीं, सिर्फ़ summary counts।
  • -fChildren को भी follow करो — shells और servers के लिए ज़रूरी।

Expected output

Calls, errors और time की table, cost के हिसाब से sorted।

आम error

-f भूल जाना और ये समझ लेना कि program 'कुछ करता ही नहीं' जबकि असली काम उसकी children कर रही हैं।

Safe usage

सिर्फ़ अपने programs। अनजान binaries के लिए Domain 18 का isolated environment।

Security implication

जो syscall set एक program को SACH MEIN चाहिए, वही उसके लिए एक tight seccomp policy लिखने का input है।
grep -E 'Seccomp|CapEff|NoNewPrivs' /proc/self/status

Y01-P01-D01-M02-C03-T01-L01 · Privilege Boundary: User Mode, Kernel Mode और Syscall

Purpose

Current process का seccomp mode, effective capabilities और no-new-privs flag दिखाता है।

Syntax

grep -E '...' /proc/<pid>/status

Expected output

Seccomp: 0 (off), 1 (strict) या 2 (filter); CapEff एक hex capability mask; NoNewPrivs 0 या 1।

आम error

CapEff को सिर्फ़ number समझ लेना — उसको decode करो: `capsh --decode=<value>`

Safe usage

सिर्फ़ पढ़ता है।

Security implication

Live host पे ये पता करने का तरीक़ा है कि एक process ASLI में किस चीज़ से confined है — hardening review और incident triage दोनों में routine step।
capsh --decode=<hexmask>

Y01-P01-D01-M02-C03-T01-L01 · Privilege Boundary: User Mode, Kernel Mode और Syscall

Purpose

Capability bitmask को पढ़ने लायक़ नामों में बदलता है।

Syntax

capsh --decode=0000003fffffffff

Expected output

Comma से अलग list जैसे cap_chown,cap_dac_override,…

आम error

capsh install नहीं है — libcap2-bin या equivalent package चाहिए।

Safe usage

सिर्फ़ पढ़ता है।

Security implication

Capabilities root को टुकड़ों में तोड़ती हैं। पर CAP_SYS_ADMIN लगभग पूरा root है — इसलिए किसी container को वो देना मतलब boundary हटा देना।
ip -brief addr

Y01-P01-D01-M03-C02-T01-L01 · अपना Isolated Lab बनाओ — और उसकी isolation PROVE करो

Purpose

Interfaces और उनके addresses छोटी table में दिखाता है, ताकि confirm हो कि guest सिर्फ़ EK network पे है।

Syntax

ip -brief addr [show <iface>]

Expected output

हर interface की एक line: नाम, state, addresses।

आम error

पूरा `ip addr` output लंबा होता है इसलिए दूसरा adapter नज़र से छूट जाता है — brief form उसको साफ़ दिखा देता है।

Safe usage

सिर्फ़ पढ़ता है।

Security implication

नज़र से छूट गया दूसरा interface — 'isolated' lab के isolated NA होने का सबसे common reason यही है।
curl -m 5 -sS https://example.com >/dev/null; echo exit=$?

Y01-P01-D01-M03-C02-T01-L01 · अपना Isolated Lab बनाओ — और उसकी isolation PROVE करो

Purpose

Hard timeout के साथ internet access test करता है और सिर्फ़ exit code बताता है।

Syntax

curl -m <seconds> -sS <url>

Parameters

  • -mMaximum total time — वरना hang isolation जैसा दिखता है।
  • -sSचुप रहो, पर errors फिर भी दिखाओ।

Expected output

Isolated lab में non-zero exit code। Zero का मतलब आप isolated NAHI हो।

आम error

-m ना लगाना और लंबे hang को isolation का proof समझ लेना।

Safe usage

सिर्फ़ एक well-known public site पे request, सिर्फ़ अपनी connectivity test करने के लिए।

Security implication

ये एक NEGATIVE test है — आप किसी चीज़ की ग़ैरमौजूदगी prove कर रहे हो। Negative tests में timeout ज़रूरी है, वरना 'slow' को 'blocked' समझ लिया जाता है।
ss -tlnp

Y01-P01-D01-M03-C02-T01-L01 · अपना Isolated Lab बनाओ — और उसकी isolation PROVE करो

Purpose

Listening TCP sockets और उनके owner process दिखाता है।

Syntax

ss -tlnp

Parameters

  • -tTCP।
  • -lसिर्फ़ listening।
  • -nNumeric — DNS lookup मत करो।
  • -pProcess दिखाओ (privilege चाहिए)।

Expected output

हर listener का local address:port, state और process।

आम error

0.0.0.0 देख कर ये ना समझना कि इसका मतलब 'HAR interface' है — जो extra adapter होने पे बहुत मायने रखता है।

Safe usage

सिर्फ़ अपनी machines पे, read-only।

Security implication

0.0.0.0 पे bound service + एक unexpected adapter = exposed service। ये command उस सवाल का जवाब देता है: 'ASLI में reachable क्या है?'
ls -l

Y01-P01-D02-M01-C02-T01-L01 · Linux Permissions: rwx, octal, setuid और capabilities

Purpose

Files और उनके permissions, owner, group, size, time दिखाता है।

Syntax

ls -l [-a] [path]

Parameters

  • -aHidden files (जो . से शुरू होती हैं) भी दिखाओ।
  • -hSize human-readable (KB/MB)।

Expected output

हर file की एक line: `-rwxr-xr-- 1 owner group size date name`।

आम error

पहले character (file type) को permission समझ लेना — वो अलग है।

Safe usage

सिर्फ़ पढ़ता है।

Security implication

Audit का पहला tool। World-writable (rwxrwxrwx) या unexpected setuid (rws) यहीं दिखते हैं।
chmod

Y01-P01-D02-M01-C02-T01-L01 · Linux Permissions: rwx, octal, setuid और capabilities

Purpose

File/directory के permission bits बदलता है।

Syntax

chmod [octal|symbolic] <file>

Parameters

  • 755Octal: owner rwx, group r-x, other r-x।
  • u+xSymbolic: owner को execute जोड़ो, बाक़ी वैसे ही।
  • -RRecursively — पूरे folder tree पे। सावधानी से; यहीं 777 वाली ग़लती होती है।

Expected output

कोई output नहीं; `ls -l` से बदलाव verify करो।

आम error

`chmod -R 777` — पूरे tree को world-writable करना। लगभग हमेशा ग़लत।

Safe usage

बदलने से पहले सोचो: owner कौन होना चाहिए? क्या ये सचमुच group/other को चाहिए?

Security implication

ग़लत chmod सबसे common Linux misconfiguration है, और privilege escalation का सीधा रास्ता।
find / -perm -4000 -type f 2>/dev/null

Y01-P01-D02-M01-C02-T01-L01 · Linux Permissions: rwx, octal, setuid और capabilities

Purpose

पूरे system की सारी setuid files ढूँढता है।

Syntax

find <path> -perm -<mode> -type f

Parameters

  • -perm -4000जिन files में setuid bit set है।
  • 2>/dev/nullPermission-denied errors छुपाओ, सिर्फ़ results दिखाओ।

Expected output

setuid binaries की list, जैसे /usr/bin/passwd, /usr/bin/sudo।

आम error

Results और errors को गड्डमड्ड कर देना — इसलिए 2>/dev/null ज़रूरी।

Safe usage

अपने ही systems पे। ये reconnaissance है — दूसरे के system पे बिना permission मत चलाओ।

Security implication

setuid binaries privilege escalation का सबसे ज़्यादा जाँचा जाने वाला surface हैं (GTFOBins इसी की list है)।
getcap / setcap

Y01-P01-D02-M01-C02-T01-L01 · Linux Permissions: rwx, octal, setuid और capabilities

Purpose

File की Linux capabilities पढ़ता/सेट करता है — root की power का एक छोटा टुकड़ा।

Syntax

getcap <file> · sudo setcap cap_net_raw+ep <file>

Expected output

getcap: `/usr/bin/ping cap_net_raw=ep` जैसा।

आम error

setuid और capability को एक समझ लेना — capability बहुत ज़्यादा सीमित (safer) है।

Safe usage

capabilities देना setuid-root देने से हमेशा बेहतर है, अगर काम उससे चल जाए।

Security implication

CAP_SYS_ADMIN लगभग पूरा root है — उसे देना least-privilege तोड़ देता है। बाक़ी capabilities बारीक और safer हैं।
systemctl status <unit>

Y01-P01-D02-M02-C02-T01-L01 · Processes, systemd Services और Logs से Root Cause

Purpose

किसी service का अभी का हाल + आख़िरी कुछ log lines दिखाता है।

Syntax

systemctl status <unit>

Parameters

  • -lलंबी log lines पूरी दिखाओ, काटो नहीं।

Expected output

Loaded/Active state, main PID, और recent journal lines।

आम error

unit name ग़लत लिखना — exact name चाहिए (.service optional)।

Safe usage

सिर्फ़ पढ़ता है।

Security implication

failed या unexpected-running services triage का पहला step।
journalctl -u <unit>

Y01-P01-D02-M02-C02-T01-L01 · Processes, systemd Services और Logs से Root Cause

Purpose

किसी service का पूरा log इतिहास दिखाता है।

Syntax

journalctl -u <unit> [-n N] [-f] [-p err] [--since ...]

Parameters

  • -n 50आख़िरी 50 lines।
  • -fLive follow (tail जैसा)।
  • -p errसिर्फ़ error और ऊपर।
  • --since '10 min ago'समय से filter।

Expected output

Timestamped log lines।

आम error

-f लगा कर भूल जाना कि वो live wait कर रहा है (Ctrl+C से निकलो)।

Safe usage

सिर्फ़ पढ़ता है।

Security implication

Incident response में timeline यहीं से बनती है; पर याद रखो default में command args log नहीं होते।
ps -ef --forest

Y01-P01-D02-M02-C02-T01-L01 · Processes, systemd Services और Logs से Root Cause

Purpose

सारे processes को parent-child tree के रूप में दिखाता है।

Syntax

ps -ef --forest | less

Expected output

UID, PID, PPID, command — indented tree।

आम error

अकेला process देखना, parent नहीं — parent अक्सर असली सुराग़ होता है।

Safe usage

सिर्फ़ पढ़ता है।

Security implication

Unusual parent (जैसे web server से शुरू हुआ shell) compromise का classic signal है।
kill

Y01-P01-D02-M02-C02-T01-L01 · Processes, systemd Services और Logs से Root Cause

Purpose

किसी process को signal भेजता है (default: बंद होने का अनुरोध)।

Syntax

kill [-SIGNAL] <pid>

Parameters

  • -TERM (15)ठीक से बंद हो — default, safest।
  • -KILL (9)ज़बरदस्ती मारो — process cleanup नहीं कर पाता; last resort।
  • -HUP (1)अक्सर config reload।

Expected output

कोई output नहीं; process बंद/reload होता है।

आम error

सीधे -9 मारना — इससे corrupt state रह सकता है। पहले -TERM try करो।

Safe usage

सिर्फ़ अपने processes। ग़लत PID मारना दूसरी service गिरा सकता है।

Security implication

attacker अपने traces मिटाने के लिए logging/monitoring processes को kill करता है — उनका अचानक मरना एक alert होना चाहिए।
ss -tulnp

Y01-P01-D02-M03-C01-T01-L01 · Linux Networking और Host Hardening

Purpose

सारे listening sockets — कौन सा port, कौन सा process, किस address पर।

Syntax

ss -tulnp

Parameters

  • -tTCP।
  • -uUDP।
  • -lसिर्फ़ listening।
  • -nNumeric (DNS lookup नहीं)।
  • -pProcess (sudo चाहिए)।

Expected output

हर listener की line: proto, state, local addr:port, process।

आम error

0.0.0.0 को सिर्फ़ एक address समझना — इसका मतलब 'हर interface' है, यानी बाहर से पहुँच।

Safe usage

सिर्फ़ अपने hosts पर, read-only।

Security implication

'इस host की attack surface क्या है' का सीधा जवाब। हर 0.0.0.0 listener justify होना चाहिए।
ip addr / ip route

Y01-P01-D02-M03-C01-T01-L01 · Linux Networking और Host Hardening

Purpose

Interfaces, उनके IP, और routing table दिखाता है।

Syntax

ip addr · ip route · ip -brief addr

Parameters

  • -briefछोटा, साफ़ output।

Expected output

Interfaces + addresses; routes with default gateway।

आम error

पुराने ifconfig/route की आदत — अब ये deprecated हैं, ip use करो।

Safe usage

सिर्फ़ पढ़ता है।

Security implication

अनचाहा दूसरा interface (Domain 01 वाला lab isolation issue) यहीं पकड़ में आता है।
sshd -T

Y01-P01-D02-M03-C01-T01-L01 · Linux Networking और Host Hardening

Purpose

SSH server की असली, effective configuration print करता है (सारे defaults सहित)।

Syntax

sudo sshd -T | grep -Ei '<setting>'

Expected output

हर setting की एक line, जैसे `permitrootlogin no`।

आम error

सिर्फ़ sshd_config file पढ़ना — जो file में नहीं लिखा वो default होता है; -T असली effective value दिखाता है।

Safe usage

सिर्फ़ पढ़ता है।

Security implication

SSH misconfig (root login, password auth) सबसे common internet-facing weakness है; -T से पक्का पता चलता है।
nft list ruleset

Y01-P01-D02-M03-C01-T01-L01 · Linux Networking और Host Hardening

Purpose

मौजूदा nftables firewall rules दिखाता है।

Syntax

sudo nft list ruleset

Expected output

tables, chains और rules।

आम error

iptables और nftables को एक साथ mix करना — confusion होता है; एक ही चुनो।

Safe usage

list पढ़ना safe; rules बदलते वक़्त lock-out से सावधान।

Security implication

Default-drop incoming + egress filtering host hardening की रीढ़ है।
whoami /all

Y01-P01-D02-M04-C01-T01-L01 · Windows Architecture और Security Model

Purpose

Current user का SID, groups, privileges और integrity level दिखाता है।

Syntax

whoami /all

Expected output

User SID, group SIDs, privileges list, integrity level।

आम error

सिर्फ़ `whoami` (केवल नाम) चलाना — /all असली token दिखाता है।

Safe usage

सिर्फ़ पढ़ता है।

Security implication

SeDebugPrivilege/SeImpersonatePrivilege की मौजूदगी privilege escalation के रास्ते बताती है; integrity level UAC state दिखाता है।
Get-Service / Get-CimInstance Win32_Service

Y01-P01-D02-M04-C01-T01-L01 · Windows Architecture और Security Model

Purpose

Services और वे किस account/path से चलती हैं — दिखाता है।

Syntax

Get-CimInstance Win32_Service | Select Name,StartName,PathName,StartMode

Expected output

Service names, run-as account (जैसे LocalSystem), executable path।

आम error

सिर्फ़ status देखना, StartName/PathName नहीं — असली risk वहाँ है।

Safe usage

सिर्फ़ पढ़ता है (जब तक Set-Service न करो)।

Security implication

SYSTEM की तरह चलती service + writable path या unquoted path = privilege escalation (Domain 11)।
Get-WinEvent

Y01-P01-D02-M04-C01-T01-L01 · Windows Architecture और Security Model

Purpose

Windows event logs पढ़ता/filter करता है।

Syntax

Get-WinEvent -FilterHashtable @{LogName='Security';Id=4625} -MaxEvents 20

Parameters

  • -LogNameकौन सा channel (Security, System, ...)।
  • -FilterHashtableID/time से filter — बड़े logs में ज़रूरी।
  • -MaxEventsकितने events।

Expected output

Event records: time, ID, message।

आम error

बिना filter के पूरा Security log माँगना — बहुत धीमा और अपठनीय।

Safe usage

Security log के लिए admin चाहिए; read-only।

Security implication

4624/4625/4688/4672/7045 और PowerShell 4104 — detection और IR की रीढ़।
Get-ItemProperty (Registry Run keys)

Y01-P01-D02-M04-C01-T01-L01 · Windows Architecture और Security Model

Purpose

Registry की autorun locations पढ़ता है।

Syntax

Get-ItemProperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Run'

Expected output

उन programs की list जो startup पर चलते हैं।

आम error

सिर्फ़ HKLM देखना — HKCU (per-user) Run keys भी persistence रखते हैं।

Safe usage

पढ़ना safe; registry लिखते वक़्त सावधान।

Security implication

Run keys, scheduled tasks और services — persistence की तिकड़ी। Baseline से हर unexpected entry जाँचो।

02Lab verification commands

Ye wo commands hain jo lab SHURU karne se pehle chalti hain. Inka kaam ek hi hai: ye prove karna ki aapka setup waisa hi hai jaisa aap samajh rahe ho.

uname -m && nproc

Y01-P01-D01-M01-C01-T01-L01-LAB01

Purpose

Check करो कि machine 64-bit है और कितने logical CPU हैं। Lab शुरू करने से PEHLE ये चलाओ।

क्या दिखना चाहिए

`x86_64` (या Apple Silicon/ARM पे `aarch64`), फिर एक number जैसे 8।

आम ग़लती

छोटे container पे `command not found` आता है — coreutils install करो।
which gcc objdump

Y01-P01-D01-M01-C01-T01-L01-LAB01

Purpose

Confirm करो कि tools पहले से मौजूद हैं, ताकि बीच lab में अटको नहीं।

क्या दिखना चाहिए

दो paths दिखेंगे। अगर कोई missing है तो build-essential / binutils install करो।
free -h && cat /proc/meminfo | head -5

Y01-P01-D01-M01-C01-T02-L01-LAB01

Purpose

शुरू करने से पहले confirm करो कि memory stats पढ़ सकते हो।

क्या दिखना चाहिए

एक table (total/used/free/available), फिर MemTotal, MemFree, MemAvailable।

आम ग़लती

Minimal image पे `free` नहीं होता — procps install करो।
lsblk && df -hT

Y01-P01-D01-M01-C02-T01-L01-LAB01

Purpose

Lab device बनाने से PEHLE अपनी ASLI disks देख लो, ताकि बाद में confuse ना हो।

क्या दिखना चाहिए

Device tree और filesystem table। अपनी असली disk के नाम अभी लिख लो।

आम ग़लती

lsblk नहीं है — util-linux install करो।
id -u

Y01-P01-D01-M01-C02-T01-L01-LAB01

Purpose

Check करो root हो या नहीं; mount के लिए चाहिए।

क्या दिखना चाहिए

root हो तो 0। नहीं तो mount वाले steps से पहले sudo लगाना।
[ -d /sys/firmware/efi ] && echo UEFI || echo BIOS-or-legacy

Y01-P01-D01-M01-C03-T01-L01-LAB01

Purpose

पता करो system UEFI से boot हुआ या legacy से — इससे decide होगा आगे कौन से commands apply होंगे।

क्या दिखना चाहिए

या तो UEFI, या BIOS-or-legacy।

आम ग़लती

कुछ VMs legacy BIOS report करती हैं — ये असली और valid configuration है, error नहीं।
which gcc readelf ldd strace

Y01-P01-D01-M02-C01-T01-L01-LAB01

Purpose

शुरू करने से पहले confirm करो कि पूरा toolchain है।

क्या दिखना चाहिए

चार paths। Missing हो तो binutils / strace install करो।

आम ग़लती

musl-based systems पे ldd नहीं होता; वहाँ `readelf -d` use करो।
strace -c /bin/true 2>&1 | tail -5

Y01-P01-D01-M02-C03-T01-L01-LAB01

Purpose

Confirm करो कि strace चलता है और syscall counts दे सकता है।

क्या दिखना चाहिए

एक summary table जिसके अंत में total line हो।

आम ग़लती

'Operation not permitted' — ptrace_scope hardening; अपनी VM के अंदर चलाओ।
ip -brief addr

Y01-P01-D01-M03-C02-T01-L01-LAB01

Purpose

Confirm करो कि हर guest के पास SIRF lab range का address है, और कोई दूसरा नहीं।

क्या दिखना चाहिए

एक interface 10.10.10.x address के साथ, plus loopback। और कुछ नहीं।

आम ग़लती

Installation के वक़्त लगा हुआ दूसरा adapter रह गया — उसको हटाओ और दोबारा check करो।
ping -c 2 10.10.10.20

Y01-P01-D01-M03-C02-T01-L01-LAB01

Purpose

Confirm करो कि attacker और target एक दूसरे तक पहुँच रहे हैं।

क्या दिखना चाहिए

दो replies।

आम ग़लती

Target का host firewall ICMP block कर रहा हो; `ss -tlnp` से check करो कि service listen कर रही है।
ping -c 2 -W 2 1.1.1.1; curl -m 5 -sS https://example.com >/dev/null; echo exit=$?

Y01-P01-D01-M03-C02-T01-L01-LAB01

Purpose

Confirm करो कि guest internet तक NAHI पहुँच सकता। ये FAIL होना CHAHIYE।

क्या दिखना चाहिए

100% packet loss और curl का non-zero exit code। अगर ये SAFAL हो गया तो आपका lab isolated NAHI है — रुको और ठीक करो।

आम ग़लती

NAT adapter लगा रह गया है। उसको हटाओ।
ping -c 2 -W 2 <apne-asli-router-ka-ip>

Y01-P01-D01-M03-C02-T01-L01-LAB01

Purpose

Confirm करो कि guest आपके असली LAN तक नहीं पहुँच सकता। ये भी FAIL होना चाहिए।

क्या दिखना चाहिए

100% packet loss।

आम ग़लती

VM बनाते वक़्त bridged adapter चुन लिया — security lab में bridged KABHI use मत करो।
whoami && id

Y01-P01-D02-M01-C02-T01-L01-LAB01

Purpose

Confirm करो कि आप कौन हो और किन groups में हो — permissions इसी पे लगती हैं।

क्या दिखना चाहिए

आपका username, फिर uid=, gid=, groups=... की एक line।

आम ग़लती

अगर root दिख रहा है तो lab का मज़ा ख़त्म — permissions root पे लगती ही नहीं। normal user बनाओ: `sudo useradd -m test`।
systemctl --version && journalctl --version

Y01-P01-D02-M02-C02-T01-L01-LAB01

Purpose

Confirm करो systemd और journald मौजूद हैं।

क्या दिखना चाहिए

दोनों की version lines।

आम ग़लती

container में systemd नहीं चलता — पूरी VM use करो।
ip -brief addr && ip route

Y01-P01-D02-M03-C01-T01-L01-LAB01

Purpose

शुरू करने से पहले interfaces और default route देख लो।

क्या दिखना चाहिए

Interface list + एक default route।

आम ग़लती

कोई default route नहीं → host कहीं नहीं पहुँच सकता (isolated lab में ठीक है)।
$PSVersionTable.PSVersion

Y01-P01-D02-M04-C01-T01-L01-LAB01

Purpose

Confirm करो PowerShell चल रहा है और कौन सी version।

क्या दिखना चाहिए

एक version table (5.x built-in, या 7.x अगर install किया)।

आम ग़लती

cmd.exe में चला दिया — PowerShell खोलो (powershell या pwsh)।