Skip to content

Instantly share code, notes, and snippets.

@Noxwizard
Noxwizard / pe-builder.cpp
Created May 27, 2021 15:17
Building PE files from scratch
#include <Windows.h>
#include <iostream>
int main(int argc, char** argv)
{
IMAGE_DOS_HEADER dos;
memset(&dos, 0, sizeof(IMAGE_DOS_HEADER));
// Only these two fields are actually parsed
dos.e_magic = 0x5A4D; // "MZ"
dos.e_lfanew = sizeof(IMAGE_DOS_HEADER); // File address of new exe header (NT)
@Noxwizard
Noxwizard / gist:b7728b944eca38cc5ff1400fc597f7db
Created August 15, 2020 18:02
Azure Switzerland routing
C:\Users\Noxwizard>tracert 51.103.145.104
Tracing route to 51.103.145.104 over a maximum of 30 hops
1 <1 ms <1 ms <1 ms fcecda45b7a3 [192.168.1.1]
2 12 ms 24 ms 17 ms cpe-67-11-128-1.satx.res.rr.com [67.11.128.1]
3 34 ms 30 ms 41 ms tge0-0-0.snautxep01h.texas.rr.com [24.28.134.105]
4 14 ms 14 ms 12 ms agg65.snantxvy01r.texas.rr.com [24.175.33.248]
5 25 ms 22 ms 28 ms agg23.dllatxl301r.texas.rr.com [24.175.32.146]
6 19 ms 36 ms 18 ms bu-ether14.dllstx976iw-bcr00.tbone.rr.com [66.109.6.88]
@Noxwizard
Noxwizard / modtest.c
Created July 10, 2020 05:52
Parentheses matter...
#include <stdio.h>
#define VAL0 123
#define VAL1 1*123
#define VAL2 (1*123)
int main()
{
int mod0 = 2 % VAL0;
printf("mod0: %d\n", mod0);
@Noxwizard
Noxwizard / error_log
Created January 5, 2020 19:15
Conversion Error - Invalid table prefix
PHP Fatal error: Uncaught phpbb\\exception\\runtime_exception:
General Error:
SQL ERROR [ mysqli ]
Table 'phpbb30.TEForum_config' doesn't exist [1146]
SQL
SELECT config_name, config_value, is_dynamic
FROM TEForum_config
#if GCC_VERSION < 3004
/* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
If X is 0, return -1. */
int
floor_log2 (unsigned HOST_WIDE_INT x)
{
int t = 0;
#if GCC_VERSION < 3004
/* Return log2, or -1 if not exact. */
extern int exact_log2 (unsigned HOST_WIDE_INT);
/* Return floor of log2, with -1 for zero. */
extern int floor_log2 (unsigned HOST_WIDE_INT);
/* Inline versions of the above for speed. */
#else /* GCC_VERSION >= 3004 */
# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
@Noxwizard
Noxwizard / test.sql
Created December 26, 2017 21:07
MSSQL Testing
CREATE TABLE [dbo].[test](
[data] [nvarchar](100) NULL
) ON [PRIMARY]
GO
INSERT INTO dev.dbo.test VALUES ('ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ');
GO
@Noxwizard
Noxwizard / ldap.php
Created November 16, 2015 03:26
LDAP testing
<?php
// Server settings
$ldap_server = 'ip or hostname of ldap server';
$ldap_port = 389;
$ldap_user = 'domain\ldap_username';
$ldap_pass = 'ldap user password';
$ldap_base_dn = 'OU=Accounting,DC=test,DC=net';
$ldap_uid = 'sAMAccountName';
// User login test
import tcp_socket
s = tcp_socket.tcp_socket()
s.connect('localhost', 5000)
s.send('hello world')
response = s.recv()
print 'Received: ' + response