Skip to content

Instantly share code, notes, and snippets.

@hoangitk
hoangitk / windows_hardening.cmd
Created November 21, 2022 04:37 — forked from mackwage/windows_hardening.cmd
Script to perform some hardening of Windows OS
:: Windows 10 Hardening Script
:: This is based mostly on my own personal research and testing. My objective is to secure/harden Windows 10 as much as possible while not impacting usability at all. (Think being able to run on this computer's of family members so secure them but not increase the chances of them having to call you to troubleshoot something related to it later on). References for virtually all settings can be found at the bottom. Just before the references section, you will always find several security settings commented out as they could lead to compatibility issues in common consumer setups but they're worth considering.
:: Obligatory 'views are my own'. :)
:: Thank you @jaredhaight for the Win Firewall config recommendations!
:: Thank you @ricardojba for the DLL Safe Order Search reg key!
:: Thank you @jessicaknotts for the help on testing Exploit Guard configs and checking privacy settings!
:: Best script I've found for Debloating Windows 10: https://github.com/Sycnex/Windows10Debloater
:
@hoangitk
hoangitk / script-all-foreign-keys-in-MSSQL.sql
Created November 15, 2022 05:05
[Script for all Foreign Keys in MSSQL] #sql #tool
/*
Credit: sorry I forgot where I copied from
*/
--SELECT s.[name] AS [Schema],
-- t.[name] AS [Table],
-- c.column_id,
-- c.[name] AS [Column],
-- dt.[name] AS Datatype
--FROM sys.schemas AS s
--INNER JOIN sys.tables AS t ON s.[schema_id]=t.[schema_id]
@hoangitk
hoangitk / script-to-create-or-drop-all-primary-keys-MSSQL.sql
Created November 15, 2022 05:01
[Script to create and drop all Primary Keys in MSSQL] #sql #tools
/*
Credit: https://social.technet.microsoft.com/wiki/contents/articles/2321.script-to-create-or-drop-all-primary-keys.aspx
*/
DECLARE @object_id int;
DECLARE @parent_object_id int;
DECLARE @TSQL NVARCHAR(4000);
DECLARE @COLUMN_NAME SYSNAME;
DECLARE @is_descending_key bit;
DECLARE @col1 BIT;
@hoangitk
hoangitk / SurrealDb.md
Created September 22, 2022 09:20
[SurrealDB] #surrealdb

SurrealDb

Tutorials

  • Start:
     surreal start --log debug --user root --pass root memory 
     surreal sql --conn http://localhost:8000 --user root --pass root --ns test --db test --pretty
@hoangitk
hoangitk / rust.md
Created September 22, 2022 08:35
Rust #rust #install

Rust

Installation

  • WLS ref:
     sudo apt install build-essential # Install pre-reqs
     curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
@hoangitk
hoangitk / FormsAuthenticationTicketHelper.cs
Created July 19, 2022 09:29 — forked from dazinator/FormsAuthenticationTicketHelper.cs
Decrypt a Legacy ASP.NET Forms Authentication Cookie (that uses SHA1 validation, and AES encryption) - without horrendous dependencies on system.web.. This allows you to decrypt a forms authentication cookie that was created in ASP.NET 3.5, from an ASP.NET 5 application.
internal static class FormsAuthenticationTicketHelper
{
private const byte CURRENT_TICKET_SERIALIZED_VERSION = 0x01;
private const int MAX_TICKET_LENGTH = 4096;
// Resurrects a FormsAuthenticationTicket from its serialized blob representation.
// The input blob must be unsigned and unencrypted. This function returns null if
// the serialized ticket format is invalid. The caller must also verify that the
// ticket is still valid, as this method doesn't check expiration.
using System.IO.Pipelines;
using System.Net;
using System.Net.Security;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Connections.Features;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core;
var builder = WebApplication.CreateBuilder(args);
@hoangitk
hoangitk / Move docker-desktop-data distro out of System Drive.md
Created March 20, 2022 05:46
Move docker-desktop-data distro out of System Drive #docker
@hoangitk
hoangitk / Git_Practices.md
Last active March 11, 2022 06:18
[Git Practice] #git
@hoangitk
hoangitk / ExampleUsage.cs
Created November 27, 2021 04:24 — forked from NickCraver/ExampleUsage.cs
Code to mark a SQL string before it's passed to Dapper.
public static List<T> Query<T>(this DataContext db, string sql, object param = null, int? commandTimeout = null, IDbTransaction transaction = null, [CallerFilePath]string fromFile = null, [CallerLineNumber]int onLine = 0, string comment = null)
{
using (db.Connection.EnsureOpen())
{
try
{
return db.Connection.Query<T>(MarkSqlString(sql, fromFile, onLine, comment), param, transaction ?? db.Transaction, true, commandTimeout).AsDapperList();
}
catch (SqlException ex) when (ex.Is(SqlErrorCode.DatabaseReadOnly_3906))
{