Sec-88
  • πŸ§‘Whoami
  • πŸ•ΈοΈWeb-AppSec
    • Features Abuse
      • 2FA
      • Ban Feature
      • CAPTCHA
      • Commenting
      • Contact us
      • File-Upload
      • Inviting Feature
      • Messaging Features
      • Money-Related Features
      • Newsletter
      • Profile - Settings
      • Registration
      • Reset Password
      • Review
      • Rich Editor/Text
      • Social Sharing
      • Billing-Shipping Address Management
      • Integrations - Webhooks
      • API Key Management
    • Reconnaissance
      • Attacking Organizations with big scopes
    • Subdomain Enumeration
    • Fingerprinting
    • Dorking
    • XSS-HTML Injection
    • Improper Authentication
      • JWT Security
    • OAUTH Misconfigurations
      • OAuth 2.0 Basics
      • OAUTH Misconfigurations
    • Auth0 Misconfigurations
    • Broken Access Control
      • Insecure Direct Object References (IDOR)
      • 403 Bypass
    • Broken Link Injection
    • Command Injection
    • CORS
    • CRLF
    • CSRF
    • Host Header Attacks
    • HTTP request smuggling
    • JSON Request Testing
    • LFI
      • LFI to RCE
    • No Rate Limit
    • Parameters Manual Testing
    • Open Redirect
    • Registration & Takeover Bugs
    • Remote Code Execution (RCE)
    • Session Fixation
    • SQL Injection
      • SQL To RCE
    • SSRF
    • SSTI
    • Subdomain Takeover
    • Web Caching Vulnerabilities
    • WebSockets
    • XXE
      • XXE to RCE
    • Cookie Based Attacks
    • CMS
      • AEM [Adobe CMS]
    • XSSI (Cross Site Script Inclusion)
    • NoSQL injection
    • Local VS Remote Session Fixation
    • Protection
      • Security Mechanisms for Websites
      • Cookie Flags
      • SameSite Cookie Restrictions
      • Same-origin policy (SOP)
      • CSP
    • Hacking IIS Applications
    • Dependency Confusion
    • Attacking Secondary Context
    • Hacking Web Sockets
    • IDN Homograph Attack
    • DNS Rebinding Attack
    • LLM Hacking Checklist
    • Bypass URL Filtration
    • Cross-Site Path Traversal (CSPT)
    • PostMessage Security
    • Prototype Pollution
      • Client-Side Prototype Pollution
      • Server-Side prototype pollution
    • Tools-Extensions-Bookmarks
    • WAF Bypassing Techniques
    • SSL/TLS Certificate Lifecycle
    • Serialization in .NET
    • Client-Side Attacks
      • JavaScript Analysis
    • Bug Bounty Platforms/Programs
  • βœ‰οΈAPI-Sec
    • GraphQL API Security Testing
      • The Basics
      • GraphQL Communication
      • Setting Up a Vulnerable GraphQL Server
      • GraphQL Hacking Tools
      • GraphQL Attack Surface
      • RECONNAISSANCE
      • GraphQL DOS
      • Information Disclosure
      • AUTHENTICATION AND AUTHORIZATION BYPASSES
      • Injection Vulnerabilities in GraphQL
      • REQUEST FORGERY AND HIJACKING
      • VULNERABILITIES, REPORTS AND EXPLOITS
      • GraphQL Hacking Checklist
    • API Recon
    • API Token Attacks
    • Broken Object Level Authorization (BOLA)
    • Broken Authentication
    • Evasive Maneuvers
    • Improper Assets Management
    • Mass Assignment Attacks
    • SSRF
    • Injection Vulnerabilities
    • Excessive Data Exposure
    • OWASP API TOP 10 MindMap
    • Scanning APIs with OWASP ZAP
  • πŸ“±Android-AppSec
    • Setup Android App Pentesting environment on Arch
    • Setup Android App Pentesting environment on Mac M4
    • Setup Android Pentesting Environment on Debian Linux
    • Android App Fundamentals
      • Android Architecture
      • Android Security Model
      • Android App Components
        • Intents
        • Pending Intents
    • Android App Components Security Cheatsheet
    • Android App Pentesting Checklist
    • How To Get APK file for application
    • ADB Commands
    • APK structure
    • Android Permissions
    • Exported Activity Hacking
    • BroadcastReceiver Hacking
    • Content Provider Hacking
    • Signing the APK
    • Reverse Engineering APK
    • Deep Links Hacking
    • Drozer Cheat Sheet
    • SMALI
      • SMALI Cheat Sheet
      • Smali Code Patching Guide
    • Intent Redirection Vulnerability
    • Janus Vulnerability (CVE-2017-13156)
    • Task Hijacking
    • Hacking Labs
      • Injured Android
      • Hacking the VulnWebView Lab
      • Hacking InsecureBankv2 App
    • Frida Cheat Sheet
  • πŸ“ΆNetwork-Sec
    • Networking Fundamentals
    • Open Ports Security Testing
    • Vulnerability Scanning
    • Client Side Attacks
    • Port Redirection and Tunneling
    • Password Attacks
    • Privilege Escalation [PrevEsc]
      • Linux Privilege Escalation
    • Buffer Overflow (BOF)
      • VulnServer
      • Sync Breez Enterprize
      • Crashed CTF
      • BOF for Linux
    • AV Evasion
    • Post Exploitation
      • File Transfer
      • Maintaining Access
      • Pivoting
      • Clean Up
    • Active Directory
      • Basic AD Pentesting
  • πŸ’»Desktop AppSec
    • Thin Client vs. Thick Client
  • ☁️Cloud Sec
    • Salesforce Hacking
      • Basics
      • Salesforce SAAS Apps Hacking
    • Firebase
    • S3 Buckets Misconfigurations
  • πŸ‘¨β€πŸ’»Programming
    • HTML
    • JavaScript (JS)
      • window.location object
    • Python
      • Python Tips
      • Set
        • SetMethods
    • JAVA
      • Java Essentials
      • Java Essentials Code Notes
      • Java OOP1
      • JAVA OOP Principles
        • Inheritance
        • Method Overriding
        • Abstract Class
        • Interface
        • polymorphism
        • Encapsulation
        • Composition
      • Java OOP Challenges
      • Exception Handling
    • Go
      • Go Syntax Tutorial in one file
      • Methods and Interfaces
      • Go Slices
      • Go Maps
      • Go Functions
      • Concurrency
      • Read Files
      • Write Files
      • Package
        • How to make personal Package
        • regexp Packages
        • Json
        • bufio
        • Time
      • Signals-Exit
      • Unit Testing
  • πŸ–₯️Operating Systems
    • Linux
      • Linux Commands
      • Tools
      • Linux File System
      • Bash Scripting guide
      • tmux
      • Git
      • Install Go tools from private repositories using GitHub PAT
    • VPS
    • Burp Suite
  • ✍️Write-Ups
    • Hunting Methodology
    • API BAC leads to PII Data Disclosure
    • Misconfigured OATUH leads to Pre-Account Takeover
    • Automating Bug Bounty with GitHub Actions
    • From Recon to Reward: My Bug Bounty Methodology when Hunting on Public Bug Bounty Programs
    • Exploring Subdomains: From Enumeration to Takeover Victory
    • 0-Click Account Takeover via Insecure Password Reset Feature
    • How a Simple Click Can Lead to Account Takeover: An OAuth Insecure Implementation Vulnerability
    • The Power Of IDOR even if it is unpredictable IDs
    • Unlocking the Weak Spot: Exploiting Insecure Password Reset Tokens
    • AI Under Siege: Discovering and Exploiting Vulnerabilities
    • Inside the Classroom: How We Hacked Our Way Past Authorization on a Leading EdTech Platform
    • How We Secured Our Client’s Platform Against Interaction-Free Account Thefts
    • Unchecked Privileges: The Hidden Risk of Role Escalation in Collaborative Platforms
    • Decoding Server Behavior: The Key to Mass Account Takeover
    • Exploiting JSON-Based CSRF: The Hidden Threat in Profile Management
    • How We Turned a Medium XSS into a High Bounty by Bypassing HttpOnly Cookie
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Programming

JavaScript (JS)

1. Introduction to JS

var name = "hello";
var age = 19;
var field = "pentrest";
console.log(age);
console.log(name);
console.log(field);
alert(1);
confirm(1);
prompt(1);

2. Comments

console.log("Hello from JavaScript"); //in-line comment
/* this is a multi-line comment */

3. Data Types and Variables

/* Data Types: undefined, variables, null, bool, string, symbol, number, and object */
var name = "M8SZT8";
name = 8;
let ourname = "group";
const pi = 3.14;

4. Storing Variables with the Assignment Operator

var a;
var b = 3;
console.log(a);
a = 7;
b = a;
console.log(a);

5. Double Quote

// As in any language
var mystr = "I am a \"double quoted\" string inside \"quoted\"";
var mystr = 'I am a "double quoted" string inside "quoted"';
console.log(mystr);

6. Escape Sequences

// Code output: /'   single quote/"   double quote//   backslash/n   new line /r   carriage return /t   tab/b   backspace/f   form feed

7. Bracket Notation

var name = "M8SZT8";
var firstletterofname = "";
firstletterofname = name[0];
console.log(firstletterofname);

8. String Immutability

var mystr = "jello world ";
// mystr[0] = "h"; // Error
mystr = "hello world ";
console.log(mystr);

9. Find Nth Character

var name = "mszt";
var lastletterofname = name[name.length - 1];
console.log(lastletterofname);
var lastletterofname = name[name.length - 3];
console.log(lastletterofname);

10. Word Blanks

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
    var result = "";
    result += "The " + myAdjective + " " + myNoun + " " + myVerb + " " + "to the store";
    return result;
}
console.log(wordBlanks("dog", "big", "ran", "quickly"));

11. Arrays

// Example for Arrays
var ourArray = [["the universe", 42], ["everything", 101010]];
var myArray = [["Bulls", 23], ["White Sox", 45]];

// Example for Editing Arrays
var ourArray = [18, 64, 99];
ourArray[1] = 45;
var myArray = [18, 64, 99];
myArray[0] = 45;
console.log(myArray);

// Access Multi-Dimensional Arrays
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
var myData = myArray[2][1];
console.log(myData);

12. Push()

// Example Push array to other array
var ourArray = ["Stimpson", "J", "cat"];
ourArray.push(["happy", "joy"]);

// Setup
var myArray = [["John", 23], ["cat", 2]];
myArray.push(["dog", 3]);

13. Pop()

// Example Remove last element in the array
var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop();

// Setup
var myArray = [["John", 23], ["cat", 2]];
var removedFromMyArray = myArray.pop();
console.log(myArray);

14. Shift() & Unshift()

// Example remove first element from array
var ourArray = ["Stimpson", "J", ["cat"]];
var removedFromOurArray = ourArray.shift();

// Setup
var myArray = [["John", 23], ["dog", 3]];
var removedFromMyArray = myArray.shift();
// unshift add as the first element
removedFromMyArray.unshift("m8szt8");

15. Functions

// Example
function ourReusableFunction() {
    console.log("Heyya, World");
}
ourReusableFunction();

// Only change code below this line
function reusableFunction() {


    console.log("Hi World");
}
reusableFunction();

16. Return a Value from a Function

function timesFive(num) {
    return num * 5;
}
console.log(timesFive(5));

17. If Statements

// Example
function trueOrFalse(wasThatTrue) {
    if (wasThatTrue) {
        return "Yes, that was true";
    }
    return "No, that was false";
}
console.log(trueOrFalse(true));

18. Comparison with the Equality Operator

function testEqual(val) {
    if (val == 12) {
        return "Equal";
    }
    return "Not Equal";
}
console.log(testEqual(10));

19. Strict Equality Operator

function testStrict(val) {
    if (val === 7) {
        return "Equal";
    }
    return "Not Equal";
}
console.log(testStrict(7));

20. Inequality Operator

function testNotEqual(val) {
    if (val != 99) {
        return "Not Equal";
    }
    return "Equal";
}
console.log(testNotEqual(10));

Certainly! Let's continue with the JavaScript cheat sheet:

21. Strict Inequality Operator

function testStrictNotEqual(val) {
    if (val !== "17") {
        return "Not Equal";
    }
    return "Equal";
}
console.log(testStrictNotEqual("17"));

22. Greater Than Operator

function testGreaterThan(val) {
    if (val > 100) {
        return "Over 100";
    }
    if (val > 10) {
        return "Over 10";
    }
    return "10 or Under";
}
console.log(testGreaterThan(20));

23. Greater Than or Equal To Operator

function testGreaterOrEqual(val) {
    if (val >= 20) {
        return "20 or Over";
    }
    if (val >= 10) {
        return "10 or Over";
    }
    return "Under 10";
}
console.log(testGreaterOrEqual(15));

24. Less Than Operator

function testLessThan(val) {
    if (val < 25) {
        return "Under 25";
    }
    if (val < 55) {
        return "Under 55";
    }
    return "55 or Over";
}
console.log(testLessThan(45));

25. Less Than or Equal To Operator

function testLessOrEqual(val) {
    if (val <= 12) {
        return "Smaller Than or Equal to 12";
    }
    if (val <= 24) {
        return "Smaller Than or Equal to 24";
    }
    return "Greater Than 24";
}
console.log(testLessOrEqual(20));

26. Logical And Operator

function testLogicalAnd(val) {
    if (val >= 25 && val <= 50) {
        return "Yes";
    }
    return "No";
}
console.log(testLogicalAnd(30));

27. Logical Or Operator

function testLogicalOr(val) {
    if (val < 10 || val > 20) {
        return "Outside";
    }
    return "Inside";
}
console.log(testLogicalOr(15));

28. Else Statements

function testElse(val) {
    var result = "";
    if (val > 5) {
        result = "Bigger than 5";
    } else {
        result = "5 or Smaller";
    }
    return result;
}
console.log(testElse(4));

29. Else If Statements

function testElseIf(val) {
    if (val > 10) {
        return "Greater than 10";
    } else if (val < 5) {
        return "Smaller than 5";
    } else {
        return "Between 5 and 10";
    }
}
console.log(testElseIf(7));

30. Switch Statements

function caseInSwitch(val) {
    var answer = "";
    switch(val) {
        case 1:
            answer = "alpha";
            break;
        case 2:
            answer = "beta";
            break;
        case 3:
            answer = "gamma";
            break;
        case 4:
            answer = "delta";
            break;
    }
    return answer;
}
console.log(caseInSwitch(2));

Certainly! Let's continue with the JavaScript cheat sheet:

31. Default Option in Switch Statements

function switchOfStuff(val) {
    var answer = "";
    switch(val) {
        case "a":
            answer = "Apple";
            break;
        case "b":
            answer = "Bird";
            break;
        case "c":
            answer = "Cat";
            break;
        default:
            answer = "Stuff";
            break;
    }
    return answer;
}
console.log(switchOfStuff("b"));

32. Multiple Identical Options in Switch Statements

function sequentialSizes(val) {
    var answer = "";
    switch(val) {
        case 1:
        case 2:
        case 3:
            answer = "Low";
            break;
        case 4:
        case 5:
        case 6:
            answer = "Mid";
            break;
        case 7:
        case 8:
        case 9:
            answer = "High";
            break;
    }
    return answer;
}
console.log(sequentialSizes(5));

33. Returning Boolean Values from Functions

function isLess(a, b) {
    return a < b;
}
console.log(isLess(10, 15));

34. Return Early Pattern for Functions

function abTest(a, b) {
    if (a < 0 || b < 0) {
        return undefined;
    }
    return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}
console.log(abTest(2, 2));

35. Counting Cards

var count = 0;

function cc(card) {
    switch(card) {
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
            count++;
            break;
        case 10:
        case "J":
        case "Q":
        case "K":
        case "A":
            count--;
            break;
    }
    return count > 0 ? count + " Bet" : count + " Hold";
}
console.log(cc(2), cc(3), cc(7), cc('K'), cc('A'));

Certainly! Let's continue with the JavaScript cheat sheet:

36. Build JavaScript Objects

var myDog = {
    "name": "Spot",
    "legs": 4,
    "tails": 1,
    "friends": ["everything!"]
};

37. Accessing Object Properties with Dot Notation

var myObj = {
    prop1: "value1",
    prop2: "value2"
};
var prop1Value = myObj.prop1; // Accessing property using dot notation

38. Accessing Object Properties with Bracket Notation

var myObj = {
    "Space Name": "Kirk",
    "More Space": "Spock"
};
var propValue = myObj["Space Name"]; // Accessing property with spaces using bracket notation

39. Accessing Object Properties with Variables

var myObj = {
    prop1: "value1",
    prop2: "value2"
};
var prop = "prop1";
var propValue = myObj[prop]; // Accessing property using a variable

40. Updating Object Properties

var myObj = {
    prop1: "value1",
    prop2: "value2"
};
myObj.prop1 = "new value"; // Updating property value

41. Add New Properties to a JavaScript Object

var myObj = {
    prop1: "value1",
    prop2: "value2"
};
myObj.prop3 = "value3"; // Adding a new property

42. Delete Properties from a JavaScript Object

var myObj = {
    prop1: "value1",
    prop2: "value2"
};
delete myObj.prop1; // Deleting a property

43. Using Objects for Lookups

function phoneticLookup(val) {
    var result = "";
    var lookup = {
        "alpha": "Adams",
        "bravo": "Boston",
        "charlie": "Chicago",
        "delta": "Denver",
        "echo": "Easy",
        "foxtrot": "Frank"
    };
    result = lookup[val];
    return result;
}
console.log(phoneticLookup("charlie"));

44. Testing Objects for Properties

var myObj = {
    prop1: "value1",
    prop2: "value2"
};
function checkObj(checkProp) {
    return myObj.hasOwnProperty(checkProp) ? myObj[checkProp] : "Not Found";
}
console.log(checkObj("prop1"));

45. Manipulating Complex Objects

var myMusic = [
    {
        "artist": "Billy Joel",
        "title": "Piano Man",
        "release_year": 1973,
        "formats": ["CD", "8T", "LP"],
        "gold": true
    },
    {
        "artist": "Michael Jackson",
        "title": "Thriller",
        "release_year": 1982,
        "formats": ["CD", "Cassette", "LP"],
        "gold": true
    }
];

46. Accessing Nested Objects

var myStorage = {
    "car": {
        "inside": {
            "glove box": "maps",
            "passenger seat": "crumbs"
        },
        "outside": {
            "trunk": "jack"
        }
    }
};
var gloveBoxContents = myStorage.car.inside["glove box"];

47. Accessing Nested Arrays

var myPlants = [
    {
        type: "flowers",
        list: ["rose", "tulip", "dandelion"]
    },
    {
        type: "trees",
        list: ["fir", "pine", "birch"]
    }
];
var secondTree = myPlants[1].list[1];

48. Record Collection

var recordCollection = {
    2548: {
        albumTitle: "Slippery When Wet",
        artist: "Bon Jovi",
        tracks: ["Let It Rock", "You Give Love a Bad Name"]
    },
    2468: {
        albumTitle: "1999",
        artist: "Prince",
        tracks: ["1999", "Little Red Corvette"]
    },
    1245: {
        artist: "Robert Palmer",
        tracks: []
    }
};
function updateRecords(records, id, prop, value) {
    if (value === "") {
        delete records[id][prop];
    } else if (prop !== "tracks") {
        records[id][prop] = value;
    } else {
        if (records[id].hasOwnProperty("tracks")) {
            records[id].tracks.push(value);
        } else {
            records[id].tracks = [];
            records[id].tracks.push(value);
        }
    }
    return

 records;
}

49. Iterate with JavaScript While Loops

var myArray = [];
var i = 0;
while (i < 5) {
    myArray.push(i);
    i++;
}

50. Iterate with JavaScript For Loops

var myArray = [];
for (var i = 1; i <= 5; i++) {
    myArray.push(i);
}
PreviousHTMLNextwindow.location object

Last updated 10 months ago

Was this helpful?

πŸ‘¨β€πŸ’»