Skip to content

Instantly share code, notes, and snippets.

@khr0x40sh
khr0x40sh / ProfileServlet2.java
Created July 29, 2022 12:05
ProfileServlet snippet, part 2
if (!optionalLoginCookie.isPresent() || !CookieHandler.verifyLoginCookie(optionalLoginCookie.get())) {
out.println(
"<h1> You are a not authenticated, kindly login. </h1>");
request.getRequestDispatcher("login.jsp").include(request, response);
} else {
...
@khr0x40sh
khr0x40sh / ProfileServlet.java
Created July 29, 2022 12:04
ProfileServlet snippet, 1
Optional<Cookie> optionalDebugCookie = Arrays.stream(request.getCookies())
.filter(cookie -> "debug".equals(cookie.getName()))
.findAny();
//Log debug information for authenticated users
optionalDebugCookie.ifPresent(cookie -> {
logger.error(
new String(Base64.getDecoder().decode(cookie.getValue())));
});
@khr0x40sh
khr0x40sh / errorMessage.js
Last active July 29, 2022 12:03
ForgotPassword snippet
function errorMessage() {
var error = document.getElementById("error")
if (isNaN(document.getElementById("number").value))
{
// Complete the connection to mysqldb
// escalator.c45luksaam7a.us-east-1.rds.amazonaws.com
// Use credential allen:8%pZ-s^Z+P4d=h@P
error.textContent = "Under Construction"
error.style.color = "red"
@khr0x40sh
khr0x40sh / CookieHandler.java
Created July 29, 2022 11:58
CookieHandler.java snippet
//[CookieHandler.java]
public class CookieHandler {
private static final String LOGIN_COOKIE_NAME = "LoggedIn";
private static final String USERNAME = "";
private static final String PASSWORD = "";
[LoginServlet.java]
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String userName = request.getParameter("uname");
String password = request.getParameter("password");
...
@khr0x40sh
khr0x40sh / large_file_split.go
Created March 29, 2022 18:45
Golang Large file Splitter
package main
import (
"fmt"
"flag"
"bufio"
//"io"
"os"
"strings"
"golang.org/x/text/encoding/unicode"
@khr0x40sh
khr0x40sh / Invoke-NETReader.ps1
Created March 29, 2022 18:42
Powershell .NET Reader Large File Splitter
function Invoke-NETReader{
Param(
[string]$inputFile,
[string]$outputFile,
[string]$delim,
[int]$position
);
$reader = [System.IO.File]::OpenText($inputFile)
try {
@khr0x40sh
khr0x40sh / large_split.py
Created March 29, 2022 18:39
Large File Parser
#!/bin/env python
import argparse
parser = argparse.ArgumentParser(description='Script to split large files')
parser.add_argument('-f', required=True, help="Input file")
parser.add_argument('-o', default="split_output.txt", help="Output file")
parser.add_argument('-p', type=int, default=2, help="Position to keep (default is 2)")
parser.add_argument('-d', default=":",help="character to delimit on (default is ':')")
args= parser.parse_args()
@khr0x40sh
khr0x40sh / Invoke-AES256CBCPBKDF2.ps1
Last active March 17, 2022 18:27
AES 256 CBC PBKDF2 Implementation to mirror Openssl encrypt
function Invoke-AES256CBCPBKDF2
{
<#
.Synopsis
Powershell implementation of AES-cbc-256 pbkdf2
.Description
This script will take a byte array, encrypt the payload and output the byte array or base64 value.
This implementation is designed to mimic openssl's aes-cbc-256 pbkdf2 implementation.
@khr0x40sh
khr0x40sh / github_searcher.py
Last active January 28, 2022 12:27
Search github to try and find files scrubbed by commits
#!/bin/bash env python3
import requests
import argparse
parser = argparse.ArgumentParser(description='Search and pull down files from github.')
parser.add_argument('-u', dest='user', help='Github username for token authentication.')
parser.add_argument('-t', dest='token', help='Github token for token authentication.')
parser.add_argument('-o', dest='org', help='GitHub org to search. If left blank, it will search all of github.')
parser.add_argument('-s', dest='searchfile', help='The filename to be searched for. For example, .DS_Store')
@khr0x40sh
khr0x40sh / random_session_key_calc.py
Last active November 22, 2024 02:49
Random Session Key calculator based off of data from a packet capture
import hashlib
import hmac
import argparse
#stolen from impacket. Thank you all for your wonderful contributions to the community
try:
from Cryptodome.Cipher import ARC4
from Cryptodome.Cipher import DES
from Cryptodome.Hash import MD4
except Exception: