WeChall - Training - Net Ports

Challenge

题目不是考常见服务端口,而是要求 WeChall 服务器看到你的客户端源端口为 42

题面里的 "remote-port" 指的是服务器视角下的 remote port,也就是你的本地源端口。

Solution

用能绑定本地源端口的 HTTP 客户端访问挑战页:

1
2
3
$ curl --local-port 42 \
-b 'WC=YOUR_WECHALL_COOKIE' \
'http://www.wechall.net/en/challenge/training/net/ports/index.php'

Linux 默认低于 1024 的端口是 privileged port。普通用户绑定 42 会失败:

1
curl: (45) bind failed with errno 13: Permission denied

可选方案:

  • sudo curl --local-port 42(需要 sudo 权限)
  • 给 curl 加 CAP_NET_BIND_SERVICEsetcap cap_net_bind_service=+ep $(which curl)
  • 从一台有 root 权限且直连互联网的服务器发起请求

本题没有固定密码——连接源端口正确即自动通过。WeChall 服务器检测 TCP 连接的 source port,无需提交任何答案表单。