Skip to content

Instantly share code, notes, and snippets.

@hasegawayosuke
hasegawayosuke / winget-mklinks.bat
Created January 5, 2024 06:11
wingetでインストールされたバイナリへのハードリンクを %HOMEDRIVE%%HOMEPATH%\bin\ に作成する
#include <windows.h>
#include <tlhelp32.h>
#include <stdio.h>
DWORD getppid()
{
HANDLE hSnapshot = INVALUD_HANDLE_VALUE;
PROCESSENTRY32 pe32;
DWORD ppid = 0, pid = GetCurrentProcessId();
// SSRF保護の実装サンプル
// (これでも漏れがあるかも)
'use strict'
const os = require('os')
const net = require('net')
const dns = require('dns')
const http = require('http')
const https = require('https')
const myFetch = (url) => {
@hasegawayosuke
hasegawayosuke / js-and-bat.bat
Last active October 23, 2022 18:11
Polyglot of node.js / window bat file
if(""==0) {/*
@echo off
echo "BAT"
node "%~f0" %*
goto :eof
*/
console.log( "js" );
}
@hasegawayosuke
hasegawayosuke / async_rex.js
Created February 23, 2022 08:27
Asynchronous RegExp for node.js with termination
const { Worker, isMainThread, workerData, parentPort } = require('worker_threads')
if (isMainThread) {
class AsyncRex {
constructor (pattern, flags) {
if (pattern instanceof RegExp) {
this.source = pattern.source
this.flags = pattern.flags
} else if (typeof pattern === 'string') {
this.source = pattern
@hasegawayosuke
hasegawayosuke / index.js
Last active February 18, 2022 13:13
RegExp in worker_threads
// access to http://localhost:3000?n=65536
const http = require('http')
const {URL} = require('url')
const {Worker} = require('worker_threads')
const rex = /\s+$/
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
@hasegawayosuke
hasegawayosuke / owasp-top-10-2021-index.ja.md
Created September 9, 2021 04:43
OAWSP Top 10 2021 ja

この文書は https://github.com/OWASP/Top10/blob/master/2021/docs/index.md の前半を @hasegawayosuke が私的に訳したものです。正確性には欠けますので取扱いには自身で注意してください。


OWASP Top 10 2021の紹介

最新のOWASP TOP 10へようこそ! OWASP TOP 10 2021は新しいグラフィックデザイン、印刷もできる1ページのインフォグラフィックの全てが刷新されたものです。

この更新作業に時間とデータを提供してくれた全ての人に心から感謝いたします。あなたがいなければこの成果は出せませんでした。 ** ありがとうございます。 **

@hasegawayosuke
hasegawayosuke / got-with-proxy.js
Created October 20, 2020 03:48
got with proxy
const got = require('got')
const myGot = async (url) => {
const instance = got.extend({
hooks: {
beforeRequest: [
options => {
options.headers.Host = (new URL(url)).hostname
options.port = 8888
options.hostname = '127.0.0.1'
options.url = url
@hasegawayosuke
hasegawayosuke / CustomeRule.js
Last active August 17, 2020 05:58
Hide CSS files of Fiddler tracif
// Open Fiddler and Choose "Rules" menu, click "Customize Rules..." and add this code to CustomRule.js
class Handlers
{
// ....
public static RulesOption("Hide CSS")
BindPref("fiddlerscript.rules.HideCSS")
var m_HideCSS: boolean = false;
// ....
static function OnBeforeResponse(oSession: Session) {
@hasegawayosuke
hasegawayosuke / dome-event.gs
Last active July 22, 2020 14:06
東京ドームのイベント情報を通知
var slack_token = "xoxp-xxxxxxxxxxx-....";
var slack_channel = "#channnel";
function scraping(day /* 1..31 */){
var url = "https://www.tokyo-dome.co.jp/dome/event/schedule.html";
var res, pattern, html, pos1, pos2, text;
res = UrlFetchApp.fetch(url);
if (typeof day === "number" && day < 10) {
day = "0" + day;
}