EC2のインスタンスをウェブサーバとして S3を使ってNamecheapのDNSを関連付ける
メモ。
簡易的なflaskでのウェブサービスをデプロイしたりしたときにやったこと(後から書いているので漏れがあるかもしれない)。
使ったもの
EC2
サーバー設定
- とりあえず、t2.micro(なんでもいい)を作る
- セキュリティの中で、HTTPやHTTPSのポートを開ける
- sshで鯖内の初期設定をする
- flaskアプリを上げる
- 動くように設定する
- 外部からアクセスできるか試してみる
固定IP
- Elastic IPを設定する(インスタンスが死ぬと課金されるので忘れないようにする)
- だけだったっけ
Namecheap1
- 適当にドメインを買います
Route S3
- Hosted ZoneからCreate Hostet Zoneをする
- ドメインなどを設定する
- Create Record SetからValueにElastic IPを設定して紐付ける
Namechap2
- Manageをして、Domainの中のNameServicesに、Route S3で表示されたドメインを追加する
少し待つとドメインが更新される(初期設定では48時間)
参考にしたもの
Amazon Route53編~サイトを公開してみよう!パート①~ NameCheap domain name and Amazon EC2
HITCON CTF 2016 RegExpert and moRE writeup
RegExpert
RegExpert 59 Teams solved. Description Do you remember "hard to say" last year? I think this one is harder to say... nc 52.69.125.71 2171 Hint None
% cat regexp (?i)s.*e.*l.*e.*c.*t ^(a\g<1>?b)$ ^(?!(xx+)\1+$)xx+$ ^((.)\g<1>\2|.?)$ (?=^(a\g<1>?b)c)a+(b\g<2>?c)$
% cat regexp - | nc 52.69.125.71 2171 Hi! We want to hire some TRUE regular expression hackers to write firewall rules. So here are five interview questions for you, good luck! Note: After CVE-2015-4410, we reject everything contains newline, so you can just safely use ^ and $ here. ================= [SQL] ================= Please match string that contains "select" as a case insensitive subsequence. Running on test #885...Accepted :) =============== [a^nb^n] ================ Yes, we know it is a classical example of context free grammer. Running on test #370...Accepted :) ================= [x^p] ================= A prime is a natural number greater than 1 that has no positive divisors other than 1 and itself. Running on test #304...Accepted :) ============= [Palindrome] ============== Both "QQ" and "TAT" are palindromes, but "PPAP" is not. Running on test #799...Accepted :) ============== [a^nb^nc^n] ============== Is CFG too easy for you? How about some context SENSITIVE grammer? Running on test #504...Accepted :) Congratz! Here is your singing bonus: hitcon{The pumping lemma is a lie, just like the cake}
moRE
We were not able to solve this challenge in time (20 minutes delay). However, we answered all of the “questions.” So, I wrote this writeup.
11 Teams solved. Description Hi, our RegExpert, I know you want moRE. nc 52.69.125.71 2172 Hint None
First and Last of this challenge were solved by @satos___jp
% cat moRE ^(0|[1-9]\d*0000|(4|8|(([1-9]\d*|)([13579][26]|[2468][048])|[1-9]\d*0[48]))(00|))$ (xx\k<1+0>|^x)+$ (?=^-?([0369]|[147][0369]*[258]|(([258]|[147][0369]*[147])([0369]|[258][0369]*[147])*([147]|[258][0369]*[258])))+$)(?=^-?.*[02468]$)(?=^-?(?!$)(?>(|(?<B>4\g<A>|5\g<B>|6\g<C>|[07]\g<D>|[18]\g<E>|[29]\g<F>|3\g<G>))(|(?<C>[18]\g<A>|[29]\g<B>|3\g<C>|4\g<D>|5\g<E>|6\g<F>|[07]\g<G>))(|(?<D>5\g<A>|6\g<B>|[07]\g<C>|[18]\g<D>|[29]\g<E>|3\g<F>|4\g<G>))(|(?<E>[29]\g<A>|3\g<B>|4\g<C>|5\g<D>|6\g<E>|[07]\g<F>|[18]\g<G>))(|(?<F>6\g<A>|[07]\g<B>|[18]\g<C>|[29]\g<D>|3\g<E>|4\g<F>|5\g<G>))(|(?<G>3\g<A>|4\g<B>|5\g<C>|6\g<D>|[07]\g<E>|[18]\g<F>|[29]\g<G>)))(?<A>$|[07]\g<A>|[18]\g<B>|[29]\g<C>|3\g<D>|4\g<E>|5\g<F>|6\g<G>)+$)(^((?!-?0).+|0)$) (?!,)(?=^(.\g<1>.|,)$)(|((0|1))\g<2>),(|(?!\k<3+0>)[01]\g<5>)$
% cat moRE - | nc 52.69.125.71 2172 Hi, our RegExpert, do you want one moRE flag? Solve these four :P ============== [Leap Year] ============== Even my cat can code this 🐱 Running on test #6845...Accepted :) =============== [x^(n^2)] =============== We like squares: ■ □ ▢ ▣ ▤ ▥ ▦ ▧ ▨ ▩ ▪▫ Running on test #517...Accepted :) =========== [Multiple of 42] ============ The answer to life the universe and everything. Running on test #1601...Accepted :) ============= [Complement] ============== Please match x,~x where x is a binary string. Like "0,1" or "1001,0110". Running on test #1870...Accepted :) Congratz! You are now our CRO (Chief Regular Officer). ATTENTION! HUGE GIFT IS COMING! 3...2...1... (...sorry I cut the last part)
The last [Complement] is a little tricky. The essense of the answer is
^(|((0|1))\g<2>),(|(?!\k<3+0>)[01]\g<5>)$ (when extracted, ^(|((0|1))\g<2>),(|(?!\k<2+0>)[01]\g<4>)$ is correct)
First (|((0|1))\g<2>)
matches the sequence of 0,1 and each value has own nest by the recursion. Because there is ‘,’ after this part, as a whole, this part matches x of “x,~x”.
Next (|(?!\k<3+0>)[01]\g<5>)
is a little tricky(and this is the point of this question). In order to make the regexp easier, I want to show another equivalent regex.
^(?<first>|((?<value>0|1))\g<first>),(?<second>|(?!\k<value+0>)[01]\g<second>)$
so, we can see \k\<value+0> of (?!\k<value+0) references at (?\
Last part of this challenge(decoding given “huge gift”) is explained there.
今年の総括
もうすぐ今年も終わりらしいので、一応今年を振り返りたいなと思います。
1月から2月にかけて、絶対JOI春合宿行こうな!っていう気分で、蟻本を読みつつ、競プロなどをしていました。死んでからは、競技プログラミングという分野が見えなくなりました。
でしたが、なんか科オリというものに未練が残ったので、物理チャレンジ予選に出ました。封筒が送られてきたので、通ったのかなと思ったら通っていました。本戦は計10時間小さな箱の中に佇んでいましたが、結果銅賞(19~30位)でした。銅が、JOIとJPhOで定義が違いすぎるなと思いました。
↑去年よりたくさん書けたので、来年はもう少し色々かける一年でありますようにといった感じです。来年も頑張りたいと思います。
JOI本戦参加しました
人生どうでも飯田橋
あけましておめでとうございます
今年は昨年以上に忙しくなる一年だと思うので、頑張りたいと思います。
年賀状情報です。
今年もよろしくおねがいします。目標として、昨年はここで足し算を目標としたので、今年は引き算の習得を目指して行こうと思います。
定期試験とはナップザック問題のようなもの
以下試験からの逃避文章です。
定期試験とはナップザック問題のようなものだと思います。時間という有限の制限以下で、評価を最大化するためにどの勉強をするかを選ぶからそんな感じが。夏休みという時間を何一つ定期試験のために過ごしてこなかったから、あと数日でうわあぁって感じで、感覚で計画をしていくわけだから、ヤバいなという感じです。期末があるととてもソシャゲが捗りますね。最近は日本語の書き方も分からないのでとりあえず理数系科目だけでも拾って行けたらなって思いますよね・・・