├── code-review ├── README.md ├── codereview_basic.md └── php_review.md ├── active-directory ├── kerberoasting.md ├── README.md ├── asrep_roasting.md ├── ticket_attacks.md └── gpp_credentials.md ├── priv-esc ├── linux.md └── windows.md ├── enumeration ├── password_attacks.md └── common_ports_services.md ├── buffer-overflow └── simple_stack.md ├── appsec.png ├── mobile ├── README.md ├── ios.md └── android.md ├── web ├── README.md ├── 05.openredirect.md ├── 11.ssti.md ├── 15.clickjacking.md ├── 08.xpath.md ├── 13.bac_idor.md ├── 14.logicflaws.md ├── 06.ssrf.md ├── 04.sop_cors.md ├── 02.cspbypass.md ├── 01.xss.md ├── 03.csrf.md ├── 12.jwt.md ├── 09.xxe.md ├── 10.lfi-rfi.md └── 07.sqli.md ├── api ├── README.md ├── graphql.md └── rest.md ├── README.md ├── devsecops ├── devsecops_terms.md └── docker.md └── thick-client └── thick_client.md /code-review/README.md: -------------------------------------------------------------------------------- 1 | # Source Code Review 2 | -------------------------------------------------------------------------------- /active-directory/kerberoasting.md: -------------------------------------------------------------------------------- 1 | # Kerberoasting 2 | -------------------------------------------------------------------------------- /priv-esc/linux.md: -------------------------------------------------------------------------------- 1 | # Linux Privilege Escalation 2 | -------------------------------------------------------------------------------- /active-directory/README.md: -------------------------------------------------------------------------------- 1 | # Active Directory Attacks 2 | -------------------------------------------------------------------------------- /active-directory/asrep_roasting.md: -------------------------------------------------------------------------------- 1 | # AS-REP Roasting 2 | -------------------------------------------------------------------------------- /active-directory/ticket_attacks.md: -------------------------------------------------------------------------------- 1 | # Ticket Attacks 2 | -------------------------------------------------------------------------------- /enumeration/password_attacks.md: -------------------------------------------------------------------------------- 1 | # Password Attacks 2 | -------------------------------------------------------------------------------- /priv-esc/windows.md: -------------------------------------------------------------------------------- 1 | # Windows Privilege Escalation 2 | -------------------------------------------------------------------------------- /active-directory/gpp_credentials.md: -------------------------------------------------------------------------------- 1 | # GPP Credential Attacks 2 | -------------------------------------------------------------------------------- /buffer-overflow/simple_stack.md: -------------------------------------------------------------------------------- 1 | # Simple stack-based buffer overflow 2 | -------------------------------------------------------------------------------- /appsec.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nybble04/cybersec-notes/HEAD/appsec.png -------------------------------------------------------------------------------- /enumeration/common_ports_services.md: -------------------------------------------------------------------------------- 1 | # Common Ports and Service Enumeration 2 | -------------------------------------------------------------------------------- /mobile/README.md: -------------------------------------------------------------------------------- 1 | # Mobile Application Security 2 | 3 | ## OWASP Top 10 - 2016 4 | 5 | 1. Improper Platform Usage 6 | 2. Insecure Data Storage 7 | 3. Insecure Communication 8 | 4. Insecure Authentication 9 | 5. Insufficient Cryptography 10 | 6. Insecure Authorization 11 | 7. Client Code Quality 12 | 8. Code Tampering 13 | 9. Reverse Engineering 14 | 10. Extraneous Functionality 15 | -------------------------------------------------------------------------------- /web/README.md: -------------------------------------------------------------------------------- 1 | # Web Application Security 2 | 3 | ## OWASP Top 10 - 2021 4 | 1. Broken Access Control 5 | 2. Cryptographic Failures 6 | 3. Injection 7 | 4. Insecure Design 8 | 5. Security Misconfiguration 9 | 6. Vulnerable and Outdated Components 10 | 7. Identification and Authentication Failures 11 | 8. Software and Data Integrity Failures 12 | 9. Security Loggin and Monitoring Failures 13 | 10. Server-Side Request Forgery 14 | -------------------------------------------------------------------------------- /api/README.md: -------------------------------------------------------------------------------- 1 | # Application Programming Interface (API) Security 2 | 3 | ## OWASP Top 10 - 2019 4 | 5 | 1. Broken Object Level Authorization (BOLA) --> Like IDOR (resource level) 6 | 2. Broken User Authentication --> Tokens 7 | 3. Excessive Data Exposure --> Information Disclosure 8 | 4. Lack of Resources & Rate Limiting 9 | 5. Broken Function Level Authorization (BFLA) --> Like IDOR (functionality level) 10 | 6. Mass Assignment --> Being able to change more than what is allowed or being able to add an extra parameter in the request which will get processed. 11 | 7. Security Misconfiguration --> XSS from CORS 12 | 8. Injection --> Try NoSQLi 13 | 9. Improper Assets Management --> Like keeping v1 around when v6 is available 14 | 10. Insufficient Logging & Monitoring 15 | -------------------------------------------------------------------------------- /web/05.openredirect.md: -------------------------------------------------------------------------------- 1 | # Open Redirect Attacks 2 | 3 | When a website allows for redirection to an unexpected page, this is called an open redirect. Sometimes applications need to direct the traffic to another page. If a user input can influence the outcome of that redirection, an attacker can force a redirection to a fake or malicious page. 4 | 5 | Example: 6 | 7 | Assume chrome.com has an open redirect using parameter nextpage: `https://chrome.com?nextpage=https://thankyou.google.com`. An attacker can use this to trick a user into visiting attacker.com by sending the link `https://chrome.com?nextpage=https://attacker.com` or `https://chrome.com?nextpage=https%3A%2F%2Fattacker.com`. The user will most likely click the link because they trust chrome.com. 8 | 9 | **Resources** 10 | 1. [(4:16) Steal password reset token from referrer header and (4:44) Thomas Bojarski Google double open redirect bug](https://www.youtube.com/watch?v=4Jk_I-cw4WE) 11 | 2. [Phishing](https://www.youtube.com/watch?v=TswO4ULUtKY) 12 | -------------------------------------------------------------------------------- /web/11.ssti.md: -------------------------------------------------------------------------------- 1 | # Server Side Template Injection (SSTI) 2 | 3 | **What are templates?** 4 | - Files that contain static content with placeholders to add dynamic content. 5 | - These placeholders have sepcific syntax based on the **template engine** being used. 6 | 7 | **What is the issue?** 8 | - When the templating engine interprets our input as template code instead of data. 9 | - Using this we can achieve code execution within these placeholders. 10 | 11 | **Methodology** 12 | - Look for places where user input is reflected in the ouput. A template could be used. 13 | - Capture the request and send it to Burp Intruder. 14 | - Select Sniper Attack. 15 | - Add a list of payloads for different template engines. Use [hacktricks "Detect Plaintext Context"](https://book.hacktricks.xyz/pentesting-web/ssti-server-side-template-injection) 16 | - In Burp Intruder Options select "grep extract" and insert the message that comes with the reflected input. 17 | - In the intruder results, check if any of the payloads results return "49". This will give the template engine being used. 18 | - Now search for payloads that can be used in this template engine. 19 | 20 | 21 | **References** 22 | 1. [hacktricks](https://book.hacktricks.xyz/pentesting-web/ssti-server-side-template-injection) 23 | 2. [Seven Seas Security SSTI](https://www.youtube.com/playlist?list=PL1GDzLoRwyVCEG_dnWcQDbDXJSBw7lTOT) 24 | -------------------------------------------------------------------------------- /web/15.clickjacking.md: -------------------------------------------------------------------------------- 1 | # Clickjacking 2 | - Interface based attack. 3 | - Trick a user into clicking something by overlaying a harmless looking button over a hidden malicious button. 4 | - Lead to CSRF or XSS 5 | - Malicious downloads or Keyjacking 6 | 7 | ## Prevention 8 | 9 | ## X-Frame-Options Header and CSP 10 | 11 | > NOTE: CSP has precedence over X-Frame-Options 12 | 13 | 1. Prevent iframe from being embedded in all website 14 | ``` 15 | X-Frame-Options: deny 16 | Content-Security-Policy: frame-ancestors 'none'; 17 | ``` 18 | 3. Prevent iframe from being embedd in all websites except same origin websites 19 | ``` 20 | X-Frame-Options: sameorigin 21 | Content-Security-Policy: frame-ancestors 'self'; 22 | ``` 23 | 5. Allow iframe to be embedded only in some websites 24 | ``` 25 | X-Frame-Options: allow-from https://whitelist.com 26 | Content-Security-Policy: frame-ancestors whitelist.com; 27 | ``` 28 | 29 | ## Cookie Attributes 30 | ``` 31 | SameSite: Strict # Request should come from the same origin 32 | SameSite: Lax # Request should come from top level navigation (user click not script click) 33 | ``` 34 | 35 | **Resources** 36 | 1. [Intigrity: What is clickjacking](https://www.youtube.com/watch?v=_tz0O5-cndE) 37 | 2. [Intigrity: Clickjacking a DOM XSS](https://www.youtube.com/watch?v=hqXAgFQXOH0) 38 | 3. [Clickjacking Portswigger](https://portswigger.net/web-security/clickjacking) 39 | -------------------------------------------------------------------------------- /web/08.xpath.md: -------------------------------------------------------------------------------- 1 | # XPath Injection 2 | 3 | When data is stored as XML, it can be queried using a string which is called the XPATH. XPath injection is a type of attack where user input is accepted as Xpath. A a malicious input can lead to un-authorised access or exposure of sensitive information such as the structure or content of XML document. 4 | 5 | > Attacks are similar to SQL injection - SQLi attacks SQL data stores while XPathi attacks XML data stores. 6 | 7 | Example: 8 | ```xml 9 | 10 | 11 | 12 | Sam 13 | Johns 14 | This is Secret 15 | 16 | 17 | Peter 18 | Pan 19 | Ssssshh 20 | 21 | 22 | ``` 23 | 24 | Backend Query: 25 | ``` 26 | //Employee[UserName/text()='" & Request("UserName") & "' And Password/text()='" & Request("Password") & "'] 27 | ``` 28 | 29 | Payload: 30 | ``` 31 | Username : test' or 1=1 or 'a'='a 32 | Password : test 33 | ``` 34 | 35 | This will make the backend query: 36 | ``` 37 | //Employee[UserName/text()= '" & Request("UserName") & " ' And Password/text()='" & Request("Password") & "'] 38 | //Employee[UserName/text()= 'test' or 1=1 or 'a'='a' And Password/text()='test'] 39 | ``` 40 | 41 | **Resources** 42 | 1. [CybersecurityTV Video](https://www.youtube.com/watch?v=rFXDr5KVdAc) - Explains how to test. It is similar to testing SQLi where you supply invalid characters and look for XML related error messages. 43 | 2. [Hacktricks payloads](https://book.hacktricks.xyz/pentesting-web/xpath-injection) 44 | 3. [Blog for above example](https://medium.com/@shatabda/security-xpath-injection-what-how-3162a0d4033b) 45 | -------------------------------------------------------------------------------- /web/13.bac_idor.md: -------------------------------------------------------------------------------- 1 | # Broken Access Control 2 | 3 | **What is access control and how can it be exploited?** 4 | 5 | Access control and its abuse are of three types: 6 | 7 | 1. **Vertical:** restrict access to resources and actions between users of different privileges - admin and employee. 8 | 2. **Horizontal:** restrict access to resources and actions between users of same privileges - between employees. 9 | 3. **Context dependent:** restrict access to resources and actions based on the functionality flow (state of the application). Prevents the user from performing actions in the wrong order. Eg: add $1 item to the cart -> pay -> go back and add $100 items to the cart such that these items will be shipped without payment. 10 | 11 | **What is IDOR?** 12 | 13 | Insecure Direct Object Reference (IDOR) is a type of access control vulnerability which involves some form of an identifier. This identifier can be part of the parameter or the body and is user modifiable (i.e. user input is accepted and trusted). 14 | 15 | Eg: `/getinvoice/id=123` , trying different ids can reveal other invoices which might include sensitive information like address and payment details. 16 | 17 | **Testing requirements** 18 | 19 | 1. Understand all the available roles. 20 | 2. Create 2 users for each role - check between different users of the same role, check between different users of different roles. 21 | 22 | **Attack strategy** 23 | 1. Forced browsing - login as low user and paste urls of pages available only to the admin. 24 | 2. Replacing identifiers. 25 | 3. Executing JS functions from the developer console - UI elements might be hidden but the JS will be executable. 26 | 4. Use Burp extension [Autorize](https://portswigger.net/bappstore/f9bbac8c4acf4aefa4d7dc92a991af2f). 27 | 5. Use Burp match and replace. 28 | 6. For the same endpoint try different HTTP methods. 29 | 30 | **Resources:** 31 | 1. [Rana Khalil](https://www.youtube.com/watch?v=_jz5qFWhLcg&list=PLuyTk2_mYISId4_l9YET7Gv29cHcNguq-) 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cyber Security Notes 2 | ![devsecops components](./appsec.png) 3 | 4 | - This is an ever-growing checklist that expands with my never-ending learning. 🤓 5 | - Links to supplementary resources or credits are added within the notes. 6 | - I'm no expert, so feel free to raise a PR with any corrections. 7 | 8 | ## 1. Application Security Topics: 9 | 10 | ### Web Application Security 11 | - [x] OWASP Top 10 12 | - [x] XSS, CSP 13 | - [x] CSRF, CORS, SOP 14 | - [x] Open redirect 15 | - [x] SSRF 16 | - [x] SQLi 17 | - [ ] NoSQLi 18 | - [x] XPATHi 19 | - [x] XXE 20 | - [x] LFI, RFI 21 | - [x] SSTI 22 | - [x] JWT 23 | - [x] Broken Access Control, IDOR 24 | - [x] Clickjacking 25 | - [x] Business Logic Flaws 26 | - [ ] Race Conditions 27 | - [ ] HTTP Host header Attacks 28 | - [ ] OAuth 2.0 29 | - [ ] SAML 30 | - [ ] Web Socket Vulnerabilities 31 | - [ ] Insecure deserialization 32 | - [ ] Prototype Pollution 33 | - [ ] HTTP Request Smuggling 34 | - [ ] Web Cache Poisoning 35 | - [ ] DOM vulnerabilities 36 | 37 | 38 | ### Mobile Security 39 | - [x] OWASP Top 10 40 | - [x] Android 41 | - [x] iOS 42 | 43 | ### API Security 44 | - [x] OWASP Top 10 45 | - [x] REST API 46 | - [x] GraphQL 47 | 48 | ### Thick Client Security 49 | - [x] Thick/Heavy/Rich/Fat client 50 | 51 | ### DevSecOps Concepts 52 | - [x] Concepts - ShiftLeft, Agile, CI/CD, SAST/SCA 53 | - [x] Docker Security 54 | - [ ] Kubernetes Security 55 | - [ ] Threat Modeling 56 | 57 | ## 2. Network/Infrastructure Security Topics: 58 | 59 | ### Enumeration and Foothold 60 | - [ ] Common ports and services 61 | - [ ] Password cracking 62 | 63 | ### Privilege Escalation 64 | - [ ] Windows 65 | - [ ] Linux 66 | 67 | ### Buffer Overflow 68 | - [ ] Vanilla/Simple stack BoF 69 | 70 | ### Lateral movement 71 | - [ ] Pivoting and tunneling 72 | 73 | ### Active Directory Attacks 74 | - [ ] AS REP roasting 75 | - [ ] Kerberoasting 76 | - [ ] GPP credentials 77 | - [ ] Golden Ticket 78 | - [ ] Silver Ticket 79 | 80 | ### Wireless security 81 | - [ ] Wifi WPA2 82 | -------------------------------------------------------------------------------- /code-review/codereview_basic.md: -------------------------------------------------------------------------------- 1 | # Code Review Methodology 2 | 3 | **Where to find source code if not given (black box to white box)** 4 | 1. Look at client-side code. 5 | 2. Desktop or mobile app source code (decompile). 6 | 3. Leak code through a vulnerability: path traversal. 7 | 4. OSINT: Github, pastebin, etc. 8 | 9 | **Source and Sink** 10 | - **Source** - The code that allows the vulnerability to happen. Eg: `command = $_GET['c']` 11 | - **Sink** - The place where the vulnerability takes effect. Eg: `exec(command)` 12 | If data flows from the source to the sink without proper validation, then there is a vulnerability. 13 | 14 | **Tips to quickly start** 15 | 1. Search for **known dangerous functions** - see if they operate on user input. 16 | 2. **Hardcoded credentials** - API keys, encryption keys, database passwords. NOTE: This is vulnerable even on the server side. 17 | 3. The use of **weak cryptography and hashing algorithms** - MD5, SHA1, DES. 18 | 4. **Outdated dependencies** - Look for dependencies, their versions and if they are associated with any CVE. 19 | 5. Look for **revealing developer comments** - Might reveal sensitive info - ip, credentials, other files that might have sensitive info. 20 | 21 | **More comprehensive Review** 22 | 1. Focus on critical functions first (Authentication, Authorization, PII like payment or shipping, etc. 23 | 2. Follow any code that takes in use input. 24 | 3. Use SAST, SCA and secrets scanner tools. Then manually verify the results. 25 | 26 | **Some concepts covered in Paul's presentation** 27 | 1. Input Validation - Whitelist is better than blacklist. 28 | 2. Neutralize input - use parameterized/prepared statements. important for backend, to avoid vulns like sqli. 29 | 3. Neutralize output - important for frontend, to avoid reflection. 30 | 4. Data encryption 31 | 5. Memory safe functions - for C/C++, to avoid vulns like buffer overflow. 32 | 6. IDOR - to avoid access control issues. 33 | 34 | 35 | **Resources** 36 | 1. [Vickie Li - OWASP Dev Slop](https://www.youtube.com/watch?v=A8CNysN-lOM) 37 | 2. [Paul Ionescu - OWASP Dev Slop](https://www.youtube.com/watch?v=rAwxFw25x3E) 38 | 3. [Practice - OWASP Secure Coding Dojo](https://github.com/OWASP/SecureCodingDojo) 39 | -------------------------------------------------------------------------------- /web/14.logicflaws.md: -------------------------------------------------------------------------------- 1 | # Business Logic Flaws 2 | 3 | **What is it?** 4 | 5 | Business logic flaws are flaws in the design and the implementation which cause unforseen behaviour when users pass unexpected values to the target. Impact varies depending on the resulting behaviour. 6 | 7 | **Some E-commerce examples** 8 | 9 | Credits: Wesley Thijs a.k.a [The XSS Rat](https://www.youtube.com/@TheXSSrat) 10 | 11 | 1. **Client side calculations of prices in a clothing webshop** - High/Crit. This is core business for the target so any issue related to the core business will automatically be more impactful 12 | 2. **When brute forcing usernames, you get a 200 OK status when the username you are trying to brute force exists and a 403 if it does not exist on the login page** - Low. This is rather low unless those usernames really have to be secret, you'd have to brute force the login names and then you have to still guess the correct password. This is more usefull on a pentest job. 13 | 3. **Negative amounts of items on a webshop lead to negative prices** - High/Crit. This is core business for the target so any issue related to the core business will automatically be more impactful above all, impact on money directly is very important 14 | 4. **If price = integer and amount = integer and total price = interger we can overflow total price when we price * amount** - Critical. This might lead to the target returning us money which is certainly not desireable 15 | 5. **Registering with the same username as an existing user takes over the account** - Critical. Account takeovers are always higher on the severity scale 16 | 6. **The user manual might tell you that you can't deactivate super admin users, but after trying it you can** - Medium. You have to be a priviledged user to even be allowed into the user management system so this lowers the severity a bit. 17 | 7. **Field in the response that's not in the original request but does get processed by the server when you add it** - Nothing/Critical. This really depends on the fields that is being processed here. If you can change your accounttype from "User" to "Admin" This would ofcourse be a big problem. 18 | 8. **Importing products with the same name as existing ones overwrites them. Even if the products do not belong to you and you should not be able to overwrite them.** - Medium. You are already in a priviledged position before you can import products, this lowers the severity. 19 | -------------------------------------------------------------------------------- /web/06.ssrf.md: -------------------------------------------------------------------------------- 1 | # Server Side Request Forgery (SSRF) 2 | - User has the ability to modify the URLs to which a system is making requests to. 3 | - These client-side URL modifications are not validated by the server. 4 | - These URLs could be internal or extenal. 5 | 6 | Abuse Cases: 7 | - Abusing the trust relation between exterally facing victim with internal systems, to access the internal systems. 8 | - Abusing the trust relation between externally facing victin and 3rd party external system, to perform actions on the 3rd party external system. 9 | - Portscan internal networks of the externally facing server. 10 | - Connect to local services bound to localhost 11 | 12 | Bypassing Blacklist: 13 | - Encode the requests. Eg: `127.0.0.1` can be --> `127.1` OR decimal-encoded as `2130706433` OR octal-represented as `017700000001`. 14 | 15 | Bypassing libraries that disable calling internal IP addresses: 16 | - DNS Rebinding: Register a domain name that resolves to internal IP address. 17 | - HTTP Redirection: Use your own server that redirects to an internal IP address. 18 | - Inconsistencies in URL Parsing [Orange Tsai's Talk](https://www.youtube.com/watch?v=voTHFdL9S2k) 19 | 20 | How to prevent? 21 | - Validate all client supplied input data. 22 | - Use a whitelist instead of a blacklist. 23 | - Do not send raw response to the clients. 24 | - Disable HTTP Redirections. 25 | - Network segmentation to prevent port scanning. 26 | - Give the server limited outgoing network access (deny by default) by using firewalls 27 | 28 | ## Methodology 29 | - Look for requests that contain user controllable URLs (request body, request parameter, custom header, etc.) 30 | - (In-band - Basic) Try changing the url to **localhost**. See if you get the same page, same page with additional functionalities, different page. 31 | - (In-band - Network Scanning) If the URL has an **internal IP address**, you can send it to intruder to bruteforce more IPs. 32 | - (In-band - Dirbusting)- If the URL is to another website, **bruteforce directories** of that website using intruder. 33 | - (Out-band) Try to change the URL to a server that you control. 34 | - Try to URL encode 1 or 2 times to bypass regex based filters. 35 | - (Open Redirect to SSRF) If a complete URL is not being sent, and only a path is being sent like `/products/tables/productId=1`; **look for open redirects** in any of the web pages of the application. Use this open redirect path in the SSRF payload to make a request to another resource. 36 | 37 | **Resources** 38 | 1. [SSRF Rana Khalil](https://www.youtube.com/playlist?list=PLuyTk2_mYISIlDtWBIqmgJgn6CYlzHVsQ) 39 | 2. [SSRF Pwn Function](https://www.youtube.com/watch?v=RCJdPiogUIk&list=PLI_rLWXMqpSl_TqX9bbisW-d7tDqcVvOJ&index=10) 40 | 3. [Intigrity How to search for SSRF](https://www.youtube.com/watch?v=Ku6CK3Aes8Y) 41 | -------------------------------------------------------------------------------- /web/04.sop_cors.md: -------------------------------------------------------------------------------- 1 | # Same Origin Policy 2 | - Origin = protocol/scheme + domain + port number. 3 | - The same-origin policy PREVENTS **scripts** on one origin from **reading (NOT writing)** data from another origin. 4 | - This prevents websites from attacking each other. 5 | - Enforced by the browsers. 6 | 7 | > NOTE: SOP allows embedding of images via the `` tag, media via the `