Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript challenge #47

Merged
merged 4 commits into from
Sep 18, 2020
Merged

Javascript challenge #47

merged 4 commits into from
Sep 18, 2020

Conversation

masterT
Copy link
Contributor

@masterT masterT commented Sep 10, 2020

Deux challenges web frontend #15.

  • login 1 - très facile : le drapeau est encodé avec les valeurs décimales
  • login 2 - moyen difficile : obfuscation + "encryption" maison bidon

Writeup

Login 1

  • FLAG-e7ebfbb9dcf5cfb60ae1bb59d40f7695

Pour voir le drapeau il suffit d'évaluer la chaîne de caractères "\x46\x4c\x41\x47\x2d\x65\x37\x65\x62\x66\x62\x62\x39\x64\x63\x66\x35\x63\x66\x62\x36\x30\x61\x65\x31\x62\x62\x35\x39\x64\x34\x30\x66\x37\x36\x39\x35" dans la console du navigateur.

Login 2

  • FLAG-1fbeb0a21f8d1286086ca419079c62f8a

Avant tout il faut comprendre ce que le code JavaScript fait, pour ce faire on indente correctement le script, puis on renomme les fonctions et variables.

Par la suite il faut programmer une solution qui fait l'inverse de la fonction d'encryption.

Voici une solution qui affiche le drapeau dans la console du navigateur, lorsqu'exécutée dans celle-ci.

var cipher = "NzE6NzQ6Njc6Nzg6NDM6NTY6OTY6MjoxMDU6Nzo1MzoxMDU6NTA6NTY6OTg6NTE6OTg6ODM6NDg6OTc6NTU6NTQ6NTY6NjU6MTA1OjEwNDo1MDo4Mzo2MTo4OTo1Mjo2NToxMDE6NjU6NTQ6MTEzOjYyOjM";
var key = "2718587a3f";

function keyValueAt(key, index) {
  var value;
  var keyIndex = index % key.length;
  var integer = parseInt(key[keyIndex]);
  if (integer && !isNaN(integer)) {
    value = integer;
  } else {
    value = key.charCodeAt(keyIndex);
  }
  return value;
}

function decrypt(key, cipherBase64) {
  var plaintext = '';
  var cipher = atob(cipherBase64).split(':');

  for (let i = 0; i < cipher.length; i++) {
    var code = parseInt(cipher[i]);
    if (code % 2 == 0) {
      code = code + 1;
    } else {
      code = code - 3;
    }
    var char = String.fromCharCode(code ^ keyValueAt(key, i));
    plaintext += char;    
  }

  return plaintext;
}

console.log(decrypt(key, cipher));

Copy link
Member

@CycleOfTheAbsurd CycleOfTheAbsurd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Les challenges sont bons, mais pt mettre plus d'infos pour guider les nouvelleaux dans le README ou l'index

version: "2"
services:
web:
build: .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comme y'a rien dans le Dockerfile, on pourrait mettre l'image direct ici. image: php:7.4.7-apache au lieu de build.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I guess this is what you requested.

# JavaScript

> web

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense que ça serait bien de mettre un peu d'info sur la console javascript dans la description du challenge. Genre: ça existe, on peut s'en servir pour exécuter du js ou voir des variables/fonctions qui existent dans la page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right!

@xshill xshill linked an issue Sep 17, 2020 that may be closed by this pull request
@masterT
Copy link
Contributor Author

masterT commented Sep 18, 2020

Ouin je pense que je vais laisser ça comme c'est, on pourrait ajouter quelque chose dans la section d'aide pour orienter le monde sur les défis de web.

@AXDOOMER AXDOOMER force-pushed the master branch 2 times, most recently from 77f5404 to e4c313c Compare September 18, 2020 00:47
@xshill xshill merged commit e2bff33 into master Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Track Web - JavaScript
3 participants