Captain Kirk has coded this Perl script for all his fellow-captains
to automate their logging. This way they don't have to record their logs
on tape, but they can type them in and archive them. But this log only
seems to log one log?! It automatically deletes all previous logs! Fix
the script for him, so they can keep their logs again! Captain Kirk
给同僚写了一个自动记日志的 Perl 脚本,但每次只留下一条日志,
之前的全被删掉;把它修好,让日志能留存下来。
#!/usr/bin/perl # Captain Kirk has coded this Perl script for all his fellow-captains # to automate their logging. # This way they don't have to record their logs on tape, but they can type them in # and archive them. But this log only seems to log one log?! # It automatically deletes all previous logs! Fix the script for him, # so they can keep their logs again! print'> Hello Captain ' . $ENV{'USER'} . '.' . "\n"; open(STARTREKLOG, '>/var/log/startrek'); print'> Please enter your log data here, end with a "." on a single line.' . "\n"; my$LogText; print'> '; while (<STDIN>) { unless ($_ne'.' . "\n") { last; } $LogText .= $_; print'> '; } print'> Log is being saved to /var/log/startrek' . "\n"; $DateTime = localtime(); print STARTREKLOG ' -- START OF LOG -- ' . "\n"; print STARTREKLOG 'Date/Time: ' . $DateTime . "\n"; print STARTREKLOG 'Log : ' . $LogText; print STARTREKLOG ' -- END OF LOG -- ' . "\n"; die('> Log saved! Now exiting.' . "\n");
页面只有一处输入:隐藏的 formkey、隐藏的
lvl,以及文本框 pass。底部另有全局提醒
All missions are case sensitive. I tried to keep them lowercase however.。答案大小写敏感。
import argparse import hashlib import os import re import urllib.parse import urllib.request
UA = ("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) " "Chrome/131.0.0.0 Safari/537.36") BASE = "https://www.hackthissite.org" LEVEL = BASE + "/missions/playit/extbasic/9/" TEMPLATE = BASE + "/missions/extbasic/template.php" PROFILE = BASE + "/user/view/{user}/" COOKIE = os.environ.get("HTS_COOKIE", "") USER = os.environ.get("HTS_USER", "")
defformkey_of(page): match = re.search(r'name="formkey"\s+value="([^"]+)"', page) ifnotmatch: raise SystemExit("formkey not found (session expired?)") returnmatch.group(1)