pwnable.kr第二遍---mistake

本文通过分析mistake谜题中的代码段,详细解释了如何利用优先级和条件判断的特性来解决问题。重点在于理解open()和read()函数的使用及赋值与比较运算符的区别。
>>>>>mistake
解题思路:
题目给出了hint,主要是优先级priority
其中关键点在于两个if语句
if(fd=open("/home/mistake/password",O_RDONLY,0400)<0){"error"}
if(!(len=read(fd,pw_buf,PW_LEN)>0)){"error"}
这里主要用到的是'='与'<' '>'之间优先级的关系
赋值号'='的优先级最低
因此。
第一句为:open()函数成功后返回值大于零,判断后得到false,赋值给fd后得到fd=0
第二句为:read(fd=0,...,...)表示从标准输入读取长度为10的字符串
接下来与用户输入的password进行异或比较
匹配成功后即可拿到flag
/./..-.-.-............................................../../....-..../-.....-............../.../.../../.../--.-.--.-.-..-..--...-.-/...-./-.---.-.-.-----.--.......-............../.../......./../.../........-.-----.-../........./../.../.....-.--.-......-.................................../-.--..-..-..-....-./....../..../..-....----.-.....--.....--/-.-./.....---..-..--.........-...............././..../../...-----.....-.................-../.-../....-/..../....../.../../..--.-.---.-.....-............./............./././.../........-.-............../..././---......./.../././././--.---.-................................../.../---............./.././----------.../././././././././-----...................../././..././---.../........../././././---.-........../../../../../-..../../..././-........./----...................................././../-...................../.././.././../-................/.././--................../.././..././-......................./.../.././././-.........../../-.--.-......-............/..././....././--...../.../././././--........./---.-..-...../../../.././-........./././-..../../-.---.........../........././......../..././././--....-.......................././.././.../--.......././--.-..-..-................./../../....../.././---.-...................../../../../../././---...-.-./../../-.-----..---....../.././././././././--.--....................../...././././---.........../././././--.-...../-...../../../../--........../././-.....././-.-............................../././--.................././../../././---................../../.././././-....................././..././----..-........../../.../././--..-............/....././-..-......................../././././--....../././././-........../././----..-./......./../../../--......./.././-..../.././---.............................../../.././-......-......................../.././...../.../../-.././
最新发布
11-25
x@pi:~/WiringPi/WiringPi $ sudo apt install -y python3-rpi.gpio python3-spidev python3-can # 通过 pip 安装最新版 (可选) sudo pip3 install RPi.GPIO spidev python-can Reading package lists... Done Building dependency tree... Done Reading state information... Done python3-spidev is already the newest version (20200602~200721-1+bookworm). The following additional packages will be installed: python3-msgpack python3-packaging rpi.gpio-common Suggested packages: python-can-doc The following packages will be REMOVED: python3-rpi-lgpio The following NEW packages will be installed: python3-can python3-msgpack python3-packaging python3-rpi.gpio rpi.gpio-common 0 upgraded, 5 newly installed, 1 to remove and 159 not upgraded. Need to get 301 kB of archives. After this operation, 1,467 kB of additional disk space will be used. Get:2 http://mirrors.zju.edu.cn/raspbian/raspbian bookworm/main armhf python3-packaging all 23.0-1 [32.5 kB] Get:1 http://raspbian.raspberrypi.com/raspbian bookworm/main armhf python3-msgpack armhf 1.0.3-2+b1 [62.0 kB] Get:3 http://mirrors.zju.edu.cn/raspbian/raspbian bookworm/main armhf python3-can all 4.1.0-1 [179 kB] Get:4 http://raspbian.raspberrypi.com/raspbian bookworm/main armhf rpi.gpio-common armhf 0.7.1~a4-1+b2 [6,808 B] Get:5 http://raspbian.raspberrypi.com/raspbian bookworm/main armhf python3-rpi.gpio armhf 0.7.1~a4-1+b2 [21.2 kB] Fetched 301 kB in 4s (85.8 kB/s) (Reading database ... 137316 files and directories currently installed.) Removing python3-rpi-lgpio (0.6-0~rpt1) ... Selecting previously unselected package python3-msgpack. (Reading database ... 137301 files and directories currently installed.) Preparing to unpack .../python3-msgpack_1.0.3-2+b1_armhf.deb ... Unpacking python3-msgpack (1.0.3-2+b1) ... Selecting previously unselected package python3-packaging. Preparing to unpack .../python3-packaging_23.0-1_all.deb ... Unpacking python3-packaging (23.0-1) ... Selecting previously unselected package python3-can. Preparing to unpack .../python3-can_4.1.0-1_all.deb ... Unpacking python3-can (4.1.0-1) ... Selecting previously unselected package rpi.gpio-common:armhf. Preparing to unpack .../rpi.gpio-common_0.7.1~a4-1+b2_armhf.deb ... Unpacking rpi.gpio-common:armhf (0.7.1~a4-1+b2) ... Selecting previously unselected package python3-rpi.gpio. Preparing to unpack .../python3-rpi.gpio_0.7.1~a4-1+b2_armhf.deb ... Unpacking python3-rpi.gpio (0.7.1~a4-1+b2) ... Setting up rpi.gpio-common:armhf (0.7.1~a4-1+b2) ... Setting up python3-rpi.gpio (0.7.1~a4-1+b2) ... Setting up python3-packaging (23.0-1) ... Setting up python3-msgpack (1.0.3-2+b1) ... Setting up python3-can (4.1.0-1) ... Processing triggers for man-db (2.11.2-2) ... error: externally-managed-environment × This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install. If you wish to install a non-Debian-packaged Python package, create a virtual environment using python3 -m venv path/to/venv. Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make sure you have python3-full installed. For more information visit http://rptl.io/venv note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification. x@pi:~/WiringPi/WiringPi $
06-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值