Skip to content

Instantly share code, notes, and snippets.

View wrongbyte's full-sized avatar
🍊
I like orange juice

wrongbyte

🍊
I like orange juice
View GitHub Profile
const fs = require('fs');
const path = require('path')
filePath = process.argv[2]
extension = '.' + process.argv[3]
fs.readdir(filePath, function(err, lsContent){
if (err) return console.error(err)
lsContent = lsContent.filter(lsContent => path.extname(lsContent) == extension);
for (let i = 0; i < lsContent.length; i++){
@wrongbyte
wrongbyte / test.js
Last active September 22, 2021 12:10
catch errors from JSON.parse (from nodeschool workshop)
// Some invalid JSON will be available on process.argv[2].
// Build a function called `parsePromised` that creates a promise,performs `JSON.parse` in a `try`/`catch` block, and fulfills or rejects the promise depending on whether an error is thrown.**Note:** your function should synchronously return the promise!
// Build a sequence of steps like the ones shown above that catchesany thrown errors and logs them to the console.
JSONdata = process.argv[2]
function parsePromise(data) {
return new Promise(function(fulfill, reject){
try{
parsedData = JSON.parse(data)
@wrongbyte
wrongbyte / anime-quote-disc-bot.js
Last active October 3, 2021 16:43
simplest bot ever
// Get random anime quotes by sending 'quote'
// requires nodeJS v >= 16
const Discord = require('discord.js');
const axios = require('axios');
const client = new Discord.Client({ intents: ['GUILDS', 'GUILD_MESSAGES']});
async function getAnimeQuote(){
let res = await axios.get('https://animechan.vercel.app/api/random');
quote = res.data.quote
@wrongbyte
wrongbyte / asciiArt.js
Last active November 1, 2021 14:08
Printe letrinhas bonitinhas com nodeJS
const L = parseInt(process.argv[2]);
const H = parseInt(process.argv[3]);
const T = process.argv[4];
/* exemplo: node asciiArt.js 5 5 ESSE_CODIGO_TA_RUIM
##### #### #### ##### #### # #### ##### #### # ##### # #### # # ##### # #
# # # # # # # # # # # # # # # # # # # # # ## ##
#### # # #### # # # # # # # # # # # ##### #### # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # #
##### #### #### ##### #### # #### ##### #### # # # # # # ##### ##### # #
@wrongbyte
wrongbyte / css.md
Last active January 8, 2022 14:03
Artigos sobre CSS em português e inglês
// single line comments use a double slash
(* multi line comments use (* . . . *) pair
-end of multi line comment- *)
// ======== "Variables" (but not really) ==========
// The "let" keyword defines an (immutable) value
let myInt = 5
let myFloat = 3.14
let myString = "hello" //note that no types needed
let cards = [0..5]
let hand = []
let drawCard (tuple: int list * int list) =
let deck = fst tuple // lembre-se que fst é da forma fst()
let draw = snd tuple
let firstCard = deck.Head
printfn "%i" firstCard
let hand =
@wrongbyte
wrongbyte / structs.c
Created February 19, 2022 20:40
structs em C, algo meio object oriented idk
// ref from https://www.alicemaz.com/writing/program.html
// it gets easier to reason about structs being only a definition of how much space we need to allocate for a "composite" data type.
typedef struct Android Android;
struct Android {
char *name;
char *secret_name;
unsigned int kills;
bool on_mission;
};
#!/bin/bash
# ------------------- Install GTK dracula theme -------------------
sudo apt install gnome-tweaks --noconfirm
mkdir .themes
cd tmp
wget https://github.com/dracula/gtk/releases/download/v3.0/Dracula.tar.xz
tar -xf Dracula.tar.xz -C ../.themes
gsettings set org.gnome.desktop.interface gtk-theme "Dracula"
gsettings set org.gnome.desktop.wm.preferences theme "Dracula"
@wrongbyte
wrongbyte / bcrypt.md
Last active December 19, 2024 03:10
Cracking a hashed password

Cracking a hashed password

Given a hashed password $2y$12$Dwt1BZj6pcyc3Dy1FWZ5ieeUznr71EeNkJkUlypTsgbX1H68wsRom, we have only one hint: the password has four letters, all lowercase.

Let's start: finding the hash type

There are a lot of hashes out there. A good way to start is to look at the hashed pass and try to find some kind of pattern. Here, the key is the first 4 characters of the hash. There is a page where you can look at example hashes: https://hashcat.net/wiki/doku.php?id=example_hashes Noticed something? We are looking for the bcrypt $2*$, Blowfish (Unix). Our $2y$ matches this pattern. So we are looking for a bcrypt hash. We also can grasp that the hash was generated using a factor of 12 (it is the number that comes after the first four characters).

Let's crack!

First, it is important to know how the proccess works. Hashing is a process essentially different from encryption - you can only do it once. It means that we cannot really recover the plaintext of a hashed