Skip to content

Instantly share code, notes, and snippets.

View mazrean's full-sized avatar

Shunsuke Wakamatsu mazrean

View GitHub Profile
@mazrean
mazrean / numeron.py
Last active April 9, 2020 06:37
python3で書いたnumeron
import random
def is_continue():
while True:
print("do you continue?(y/n):")
ANS = input()
if ANS == "y":
return True
elif ANS == "n":
@mazrean
mazrean / hash.go
Created November 6, 2020 10:48
ictscのhash.go
package main
import (
"fmt"
)
func Uint64ToBytes(v uint64) []byte {
var result []byte
for i := 64 - 8; i >= 0; i -= 8 {
result = append(result, byte((v>>uint64(i))&0xff))
@mazrean
mazrean / users_controller.rb
Created December 4, 2020 18:29
Bug Shooting Challenge 事前問題2
class UsersController < ActionController
def show
user = User.where(["id = ?", params[:id].to_i]).select("id, name, created_at, updated_at").first
render json: user
end
end

wanictf2020 pwn

SQL_challenge_1

index.phpを見ると '/\|が使えない。 1_scheme.sqlを見てテーブルの構造を確認する。 WHEREの条件がyears=yearsになれば全件表示される。 よって、クエリパラムをyear=yearsにすればよい。

別解:

  • year=(1)OR(1)でも任意のカラムでtrueになりOK
@mazrean
mazrean / go.mod
Last active October 12, 2021 16:14
anke-to db fix
module anke-to-fix
go 1.17
require (
gorm.io/driver/mysql v1.1.2
gorm.io/gorm v1.21.16
)
require (
❯ TF_LOG=DEBUG terraform apply
2022-01-10T13:12:00.960+0900 [INFO] Terraform version: 1.1.3
2022-01-10T13:12:00.960+0900 [INFO] Go runtime version: go1.17.2
2022-01-10T13:12:00.960+0900 [INFO] CLI args: []string{"/Users/mazrean/.asdf/installs/terraform/1.1.3/bin/terraform", "apply"}
2022-01-10T13:12:00.961+0900 [DEBUG] Attempting to open CLI config file: /Users/mazrean/.terraformrc
2022-01-10T13:12:00.961+0900 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2022-01-10T13:12:00.961+0900 [INFO] Loading CLI configuration from /Users/mazrean/.terraform.d/credentials.tfrc.json
2022-01-10T13:12:00.961+0900 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2022-01-10T13:12:00.961+0900 [DEBUG] ignoring non-existing provider search directory /Users/mazrean/.terraform.d/plugins
2022-01-10T13:12:00.961+0900 [DEBUG] ignoring non-existing provider search directory /Users/mazrean/Library/Application Support/io.terraform/plugins
// https://developers.slashdot.org/comments.pl?sid=33602&cid=3636102 より
public interface MessageStrategy {
public void sendMessage();
}
public abstract class AbstractStrategyFactory {
public abstract MessageStrategy createStrategy(MessageBody mb);
}
public class MessageBody {
@mazrean
mazrean / main.go
Last active May 11, 2022 19:29
Golang Image Square Resize
package main
import (
"flag"
"fmt"
"image"
"image/draw"
"image/png"
"os"
"path/filepath"
@GrabConfig(systemClassLoader=true)
@Grab(group='info.picocli', module='picocli', version='4.7.5')
@Grab(group='io.github.classgraph', module='classgraph', version='4.8.90')
import groovy.cli.picocli.CliBuilder
import io.github.classgraph.ClassGraph
import io.github.classgraph.ScanResult
import java.lang.reflect.Modifier
def cli = new CliBuilder(name:'MethodList', header:'List all public methods in the specified classpath')
module example
go 1.21.5
require (
github.com/gin-gonic/gin v1.9.1
github.com/mazrean/formstream v1.1.0
)
require (