Skip to content

Instantly share code, notes, and snippets.

View AH-dark's full-sized avatar

AHdark AH-dark

View GitHub Profile
@AH-dark
AH-dark / Dockerfile
Last active April 2, 2024 16:43
Dockerfile of telegram bot api server
FROM debian:bookworm AS builder
WORKDIR /build
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
make \
git \
zlib1g-dev \
libssl-dev \
gperf \
@AH-dark
AH-dark / kaypair_test.go
Last active November 1, 2023 09:32
Go asymmetric encryption and decryption tool lib
package utils
import (
"github.com/stretchr/testify/assert"
"testing"
)
var algos = []SignatureAlgorithm{
SignatureAlgorithmRSA2048,
SignatureAlgorithmRSA4096,
@AH-dark
AH-dark / primality_test.cpp
Last active July 31, 2023 18:29
Miller–Rabin primality test
#include <cstdlib>
#include <ctime>
// Function to compute (a * b) % mod for large numbers (to prevent overflow)
long long fastMultiply(long long a, long long b, long long mod) {
long long res = 0;
while (b > 0) {
if (b & 1) {
res = (res + a) % mod;
}
@AH-dark
AH-dark / telegram_bot.proto
Created May 14, 2023 05:05
Protobuf for telegram bot api
syntax = "proto3";
package telebot;
option go_package = "telebot";
message user {
sint64 id = 1;
optional bool is_bot = 2;
optional bool is_premium = 3;
optional string first_name = 4;
@AH-dark
AH-dark / postgres_backup_s3.py
Last active November 14, 2022 15:05
PostgresSQL Backup To S3 Script based on Python 3.6+
import gzip
import os
import subprocess
import time
db_name: str = ""
db_user: str = ""
db_pass: str = ""
db_host: str = ""
db_port: int = 5432
@AH-dark
AH-dark / handler.js
Created April 18, 2022 13:26
CloudFront Edge Function 防盗链功能实现
var allowDomains = [
"*.zhksb.net",
"zhksb.net",
"*.ahdark.com",
"ahdark.com"
]
function validate(input) {
if (!input) {
return true;
@AH-dark
AH-dark / screenshot.js
Last active April 17, 2022 12:28
Take screenshots of web pages with Node.js
/**
* @author AH-dark
* @describe 使用 puppeteer + 腾讯云云函数 实现网页截图API服务
* @version 1.0.1
* @url https://gist.github.com/AH-dark/8a074b2f83b1466810bb1c833ce1bdad
*
* 部署说明:
* 1. 需要腾讯云云函数服务、API网关服务
* 2. 云函数语言强制为 Nodejs 12 ,否则需要自己安装 puppeteer 依赖
* 3. 函数类型为 Event 函数,内容复制粘贴即可,执行方法为 index.main_handler
@AH-dark
AH-dark / attack.php
Created November 14, 2021 11:44
通过 wp-comments-post.php 发送大量恶意评论请求
<?php
const UAList = [
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36",
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1",
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36Edge/13.10586",
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Ubuntu/11.10 Chromium/27.0.1453.93 Chrome/27.0.1453.93 Safari/537.36",
"Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19",
@AH-dark
AH-dark / regex-cos-ci.php
Last active September 1, 2021 10:37
WordPress给文章内图片加后缀
<?php
/**
* Plugin Name: CI-Regex
* Description: 更改图片后缀为腾讯云数据万象处理后缀
* Version: 1.0.5
* Author: AHdark
* Author URI: https://ahdark.com
*/
add_filter('the_content', function($content) {
@AH-dark
AH-dark / wpjam-smtp.php
Created August 16, 2021 11:46
Amendments to the SMTP module of the WPJAM_basic plugin.
<!-- File Path: /extends/wpjam-smtp.php -->
<?php
/*
Name: SMTP 发信
URI: https://blog.wpjam.com/m/wpjam-smtp/
Description: 简单配置就能让 WordPress 使用 SMTP 发送邮件。
Version: 1.0
*/
class WPJAM_SMTP{
use WPJAM_Setting_Trait;