Skip to content

Instantly share code, notes, and snippets.

View 1ocalhost's full-sized avatar
😜
Acting cute

1ocalhost

😜
Acting cute
View GitHub Profile
@1ocalhost
1ocalhost / proxy.php
Last active July 19, 2020 13:55
PHP: file_get_contents
<?php
if (!isset($_GET['url'])) {
http_response_code(400);
die('oops!');
} else {
$url = $_GET['url'];
}
if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
http_response_code(400);
@1ocalhost
1ocalhost / .htaccess
Created May 31, 2020 12:51
Apache .htaccess Example
ErrorDocument 404 /404.html
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
@1ocalhost
1ocalhost / acl_of_shared_resource.c
Created April 29, 2020 17:58
Display ACL of shared resource
#include <windows.h>
#include <lm.h>
#include <stdio.h>
#pragma comment(lib, "Netapi32")
void print_acl(PSECURITY_DESCRIPTOR pSD)
{
ACL_SIZE_INFORMATION aclSize;
bool CheckMMX()
{
const DWORD EDX_MMX_BIT = 0x800000;// 23 bit
int cpu_info[4] = { -1 };
__cpuid(cpu_info, 0);
if (cpu_info[0] >= 1)
{
__cpuid(cpu_info, 1);
@1ocalhost
1ocalhost / menu_copy_path_winxp.reg
Created December 12, 2018 18:37
Add “Copy Path” to right click menu in Windows Explorer (for Windows XP)
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Copy Path\command]
@="mshta vbscript:Execute(\"set o=CreateObject(\"\"InternetExplorer.Application\"\")\"&vbcrlf&\"o.Navigate(\"\"about:blank\"\")\"&vbcrlf&\"o.document.parentwindow.clipboardData.setData \"\"text\"\", \"\"%1\"\"\"&vbcrlf&\"o.Quit\"&vbcrlf&\"window.close\")"
@1ocalhost
1ocalhost / node_reverse_proxy.js
Created October 27, 2018 17:52
A simple HTTP reverse proxy for node
var http = require('http');
var https = require('https');
var httpProxy = require('./libs/http-proxy');
const util = require('util');
// reverse proxy
var dstProtocol = 'https';
var dstDomain = 'doingproxy.appspot.com';
@1ocalhost
1ocalhost / parse_xiami_url.py
Created October 27, 2018 16:47
Get the music download link from xiami.com
import math
import re
import urllib, urllib2
def caesar_decrypt(data, line_num):
matrix = []
line_length = int(math.ceil(len(data) / float(line_num)))
aligned_line_num = line_num - (line_num * line_length - len(data))
@1ocalhost
1ocalhost / menu_copy_path.reg
Last active December 12, 2018 18:35
Add “Copy Path” to right click menu in Windows Explorer
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Copy Path\command]
@="mshta vbscript:CreateObject(\"wscript.shell\").Run(\"cmd /c chcp 65001 && echo | set /p x=\"\"%1\"\" | clip\",0)(window.close)"
#include <windows.h>
#include <ntsecapi.h>
#pragma comment(lib, "Secur32.lib")
bool didUserLogined()
{
ULONG logonSessionCount = 0;
PLUID logonSessionList = NULL;
NTSTATUS status = LsaEnumerateLogonSessions(
@1ocalhost
1ocalhost / hibernate.vbs
Created September 21, 2018 13:59
Hibernate Windows with friendly dialog
set shell = WScript.CreateObject("WScript.Shell")
choice = MsgBox("Are you sure to hibernate now?", 36, "Hibernate")
if choice = vbYes then
shell.run "rundll32.exe powrprof.dll,SetSuspendState"
end if