Skip to content

Instantly share code, notes, and snippets.

View wqweto's full-sized avatar

Vladimir Vissoultchev wqweto

View GitHub Profile
@wqweto
wqweto / rdplog.vbs
Created December 10, 2013 09:36
This script transfers failed logon attempts from Terminal Servers to /var/log/rdp/audit.log on the gateway server. From this point the log file is processed by fail2ban rules.
Const SSH_SERVER_LOG = "/var/log/rdp/audit.log"
Const LOCAL_RDP_GROUP = "Remote Desktop Users"
Const CACHE_AGE_IN_MINUTES = 5
Const DENY_USERS = "Administrator|Administrador|Admin|Admin1|POS|User|UsUser1|system|sys|aspnet|root|sql|post|post1|bank|operator|oper|oper1|test|test1"
Const NOLOG_USERS = "VDC02"
If Not WScript.Arguments.Named.Exists("s") Then
WScript.echo "usage: " & WScript.ScriptName & " /s:server /l:user /i:key_file"
WScript.Quit 1
End if
@wqweto
wqweto / gist:7952402
Last active March 19, 2019 09:48
Scripting.Dictionary supports For Each enumeration through IEnumVARIANT on DISPID_NEWENUM, not by using Variant array default property.
Option Explicit
Private Const LOCALE_SYSTEM_DEFAULT As Long = &H800
Private Const S_OK As Long = 0
Private Type DISPPARAMS
rgPointerToVariantArray As Long
rgPointerToLongNamedArgs As Long
cArgs As Long
cNamedArgs As Long
@wqweto
wqweto / bitclean.bat
Last active January 4, 2016 05:28
Dumps audio file bitrate
@echo off
for /f "tokens=1-2 delims=|" %%i in ('cscript //nologo bitrate.vbs /f:"%~1" /m:"%~2"') do (
if %%j LSS 320 echo %%i has bitrate %%j and will be deleted
)
@wqweto
wqweto / mdJson.bas
Last active July 4, 2023 12:28
JSON parsing and dumping functions in VB6
see https://gist.github.com/wqweto/e92dce63a68cd3ff9ca91b053b9510c9
@wqweto
wqweto / sp_foreachdb
Created December 18, 2014 16:57
Replacement for sp_msforeachdb
USE [master]
GO
IF OBJECT_ID('dbo.sp_foreachdb') IS NULL EXEC ('CREATE PROCEDURE dbo.sp_foreachdb AS RETURN 0')
GO
ALTER PROCEDURE dbo.sp_foreachdb (
@command NVARCHAR(MAX),
@replace_character NCHAR(1) = N'?',
@print_dbname BIT = 0,
@print_command_only BIT = 0,
@wqweto
wqweto / CsvExtensions.cs
Created June 8, 2015 12:48
Generic CSV formatting extension that works on `IEnumerable<T>` and returns `IEnumerable<string>`
public static class CsvExtensions
{
//
// sample usage:
//
// var list = new object[] {
// new { Email = "[email protected]", Name = "Свет.а Х,истова", UnsubscribeToken = "12\r34" },
// new { Email = "test", Name = "11\"22", UnsubscribeToken = "5\n67" },
// };
// var csv = string.Join(Environment.NewLine, list.ToCsvTable());
@wqweto
wqweto / Module1.bas
Last active December 10, 2016 10:31
[VB6] How to get friendly name, bus reported device description or "location information" for HID devices
Attribute VB_Name = "Module1"
Option Explicit
'--- for GetRawInputDeviceInfo
Private Const RIDI_DEVICENAME As Long = &H20000007
Private Const RIM_TYPEKEYBOARD As Long = 1
'--- for setupapi
Private Const DIGCF_PRESENT As Long = &H2
Private Const DIGCF_ALLCLASSES As Long = &H4
Private Const DIGCF_PROFILE As Long = &H8
@wqweto
wqweto / re.lua
Last active January 4, 2016 16:19
LPeg.re w/ optional built-in and external trace support (can be used w/ pegdebug.lua)
-- $Id: re.lua,v 1.44 2013/03/26 20:11:40 roberto Exp $
-- imported functions and modules
local tonumber, type, print, error = tonumber, type, print, error
local setmetatable = setmetatable
local m = require"lpeg"
-- 'm' will be used to parse expressions, and 'mm' will be used to
-- create expressions; that is, 're' runs on 'm', creating patterns
-- on 'mm'
@wqweto
wqweto / bf2.lua
Last active February 16, 2016 16:56
Brainfuck optimizing compiler in Lua
-- This transpiler generates Lua source code from input brainf**k program, then compiles and
-- executes this Lua source code. Can be used with LuaJIT for jitted brainf**k experience.
--
-- Based on https://github.com/prapin/LuaBrainFuck/blob/master/brainfuck.lua
-- Inspired by https://github.com/luapower/bf and its dynasm implementation (~5-10x faster)
-- Optimizations from https://www.nayuki.io/page/optimizing-brainfuck-compiler
--
-- Optimizations due to lpeg grammar:
-- instead of generating repeating `i = i + 1` just output `i = i + N`
-- instead of generating repeating `t[i] = t[i] + 1` just output `t[i] = t[i] + N`
@wqweto
wqweto / countdown.lua
Last active February 16, 2016 18:15
Countdown problem solution in Lua
--local strict = require"strict"
local function permutations(t)
local fn = coroutine.yield
local function permgen(t, n)
for i = 1, n do
t[n], t[i] = t[i], t[n]
if n == 1 then
fn(t)
else