Skip to content

Instantly share code, notes, and snippets.

Recovering deleted files in Ubuntu with ext4 filesystem

Recently, I deleted some files by mistake in a Ubuntu machine with an ext4 fs. These notes document the steps I took to get them back.

Important

  • this procedure assumes that the partition that contained the deleted files is different from the root partition, as that was the scenario with which I had to deal (deleted files were in my home dir). The procedure needs that the partition that contained the files is unmounted, so if the deleted files were in the root partition, the process would be a bit different (e.g. storing the fs journal in a USB stick, using a live CD/USB to boot and issue the commands, etc.)
  • if something is not clear, you need more information, etc. check the sources below

With that out the way, let's begin.

@hanbule
hanbule / inserting_transaction_in_db.py
Created April 10, 2025 19:22 — forked from trialan/inserting_transaction_in_db.py
Updated successful payment callback
def successful_payment_callback(update: Update, context):
col = get_collection()
receipt = update.message.successful_payment
col.insert_one({"telegram_uid": update.message.chat.username,
"donated_amount": receipt.total_amount,
"currency": receipt.currency,
"datetime": str(datetime.datetime.now())})
print_col(col)
update.message.reply_text("Thank you for your purchase!")
@hanbule
hanbule / MongoDecodeBase64.js
Created July 6, 2024 21:08 — forked from chbaranowski/MongoDecodeBase64.js
MongoDB query decode Base64 document property raw-data
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9+/=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/rn/g,"n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r
@hanbule
hanbule / scratch_2.txt
Created January 16, 2023 22:22 — forked from mikeananev/scratch_2.txt
MacOS mc Midnight commander open jar file
# jar
shell/i/.jar
Open=%cd %p/uzip://
View=%view{ascii} /usr/local/Cellar/midnight-commander/4.8.26/libexec/mc/ext.d/archive.sh view zip
# jar
type/i/^jar\ archive
Open=%cd %p/uzip://
View=%view{ascii} /usr/local/Cellar/midnight-commander/4.8.26/libexec/mc/ext.d/archive.sh view zip
@hanbule
hanbule / ubuntu20_e1000e_fix.md
Created November 6, 2022 16:38 — forked from amit177/ubuntu20_e1000e_fix.md
Ubuntu 20.04 e1000e - Reset adapter unexpectedly FIX

This guide will help you fix Ubuntu 20.04 TCP packet drops on high load with the intel e1000e driver.

Use at your own risk, I do not take any responsibility if your stuff breaks. BACKUP YOUR DATA BEFORE!

Prerequisites

To confirm this issue happens to you, look for the message Reset adapter unexpectedly in /var/log/dmesg: Use the command cat /var/log/dmesg | grep "Reset adapter unexpectedly"

If no messages show up, do the command again once you notice huge packet loss, if still nothing shows up - you're having a different issue.

@hanbule
hanbule / auto-ovpn.sh
Created August 9, 2022 08:24 — forked from lowstz/auto-ovpn.sh
Linux openvpn auto reconnect script
#!/bin/bash
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
### Thanks Xream's Work XD
# if you don't have several vpn servers to select, you can comment following line
# and use your openvpn config file name to replace "${host}.ovpn" in while loop.
read -p "Select the host: " host
#include <modloader/statichook.h>
#include <dlfcn.h>
#include <string>
static auto handshake = (size_t) dlsym(dlopen(nullptr, RTLD_LAZY), "_ZTV29ServerToClientHandshakePacket") + 0x10;
struct Packet { size_t vt; };
struct LoginPacket;
struct ClientToServerHandshakePacket;
struct NetworkIdentifier;
//frida-trace -U -i "_ZN14TransferPacket4readER12BinaryStream" com.mojang.minecraftpe
//Tested on MCPE 1.1.4
{
onEnter: function(log, args, state) {
this.ptr = args[0];
},
onLeave: function(log, retval, state) {
realAddr = Memory.readPointer(this.ptr.add(12));
rlen = Memory.readU32(realAddr.sub(12));
uint8arr = new Uint8Array(Memory.readByteArray(realAddr, rlen));
@hanbule
hanbule / dump.php
Created June 13, 2021 00:07 — forked from Frago9876543210/dump.php
bedrock_server packet tracer
<?php
declare(strict_types=1);
use pocketmine\network\mcpe\protocol\PacketPool;
use pocketmine\utils\BinaryDataException;
require_once "vendor/autoload.php";
$packetPool = PacketPool::getInstance();