纵横杯misc迷宫writeup(?

0xc0 国际惯例,先上exp

#!/usr/bin/env python
from pwn import *
context(os='linux', arch='amd64')


r=remote('182.92.203.154',11001) 
r.sendline()
r.recvuntil('start.')
from typing import *


maze = (r.recvuntil('\n>',drop=True).decode())

def find_path(maze: str) -> str:
    way = []
    maze_list = maze.split('\n')
    maze_height = len(maze_list)
    maze_width = len(maze_list[0])
    passed = [[0 for _ in range(maze_width)] for _ in range(maze_height)]

    def maze_helper(pos: Tuple[int, int]) -> bool:
        x, y = pos
        passed[y][x] = 1
        if maze_list[y][x] == '$':
            return True
        for i in 'adws':
            if i == 'a' and x > 0 and maze_list[y][x - 1] != '#' and passed[y][x - 1] != 1:
                way.append(i)
                if not maze_helper((x - 1, y)):
                    way.pop()
                else:
                    return True
            elif i == 'd' and x < maze_width - 1 and maze_list[y][x + 1] != '#' and passed[y][x + 1] != 1:
                way.append(i)
                if not maze_helper((x + 1, y)):
                    way.pop()
                else:
                    return True
            elif i == 'w' and y > 0 and maze_list[y - 1][x] != '#' and passed[y - 1][x] != 1:
                way.append(i)
                if not maze_helper((x, y - 1)):
                    way.pop()
                else:
                    return True
            elif i == 's' and y < maze_height - 1 and maze_list[y + 1][x] != '#' and passed[y + 1][x] != 1:
                way.append(i)
                if not maze_helper((x, y + 1)):
                    way.pop()
                else:
                    return True
        else:
            return False

    x, y = 0, 0
    for i, line in enumerate(maze_list):
        for j, value in enumerate(line):
            if value == '*':
                x, y = j, i
                break
        else:
            continue
        break
    maze_helper((x, y))
    return ''.join(way)

r.sendline(find_path(maze))
r.recvuntil('your win\n')

maze = (r.recvuntil('\n>',drop=True).decode())
r.sendline(find_path(maze))
r.recvuntil('your win\n')

maze = (r.recvuntil('\n>',drop=True).decode())
r.sendline(find_path(maze))
r.recvuntil('your win\n')

maze = (r.recvuntil('\n>',drop=True).decode())
r.sendline(find_path(maze))
r.recvuntil('your win\n')

maze = (r.recvuntil('\n>',drop=True).decode())
r.sendline(find_path(maze))
r.recvuntil('your win\n')

print(r.recvuntil('}',drop=False).decode())

四个迷宫,梭就完事了

小明怎么才能上网?

小明的难题

小明是中国某一不知名名校的电信学生,身在宿舍用不了网,寂寞难耐。他的墙上面板坏掉了,墙线断了,甚至在另一头的机架口也被人用松香堵上了,可谓是孤注一掷(x)现在让我们为他解决难题8

小明的室友有一个完好的面板,他想和舍友共享,但是舍友不给他路由器嫖,看来小明只能考虑其他方法了。恰好这位小朋友得知网线的1、2、3、6线是TX和RX的正负极线,也就是白橙、橙和白绿、绿。既然8根线只用了4根,小明哥要表演绝活了。

双头龙(无黄色)

我们小学二年级学过,双绞线中的B线序只有1、2、3、6被用于传输数据,如果配置适当,一根网线是可以同时建立两个物理连接而互不干扰的(如果不算电磁干扰的话)

网线结构网线结构

test

0xc0

原先写的幸运数,放在这里测试一下

#include "stdio.h"
int k1, k2;
bool isLucky(int a)
{ //isLucky(数,k1,k2)
int i, m;
for (i = 1, m = a; m / 10 >= 10; i++)
m = m / 10;
if (m == k1 || m == k2)
        return true;
    else
        return false;
}
int numOfnum(int a)
{
    int i, m;
    for (i = 1, m = a; m / 10 != 0; i++)
        m = m / 10; //判断位数i
    return i;
}
int numOfLucky(int a)
{
    int i, m, s;
    for (i = 1, m = a; m / 10 != 0; i++)
        m = m / 10; //判断位数i
    int b[i];
    for (m = i - 1, s = a; m >= 0; m--)
    {
        b[m] = s % 10;
        s = s / 10;
    } //给数组b赋上每位数
    for (m = 0, s = 0; m < i; m++)
        if (isLucky(b[m]))
            s++; //判断幸运数位数
    return s;
}
int main()
{
    int n;
    scanf("%d%d%d", &n, &k1, &k2);
    int a[n] = {0}, num[n] = {0};
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    for (int i = 0; i < n; i++)
        num[i] = numOfLucky(a[i]); //num数组与a数组一一对应
    int s = 0;
    for (int i = 1; i < n; i++)
    {
        if (num[i] > num[i - 1] && num[i] > num[s])
            s = i;
        if (numOfnum(a[i]) > numOfnum(a[s]) && num[i] == num[s])
            s = i;
    }
    printf("%d %d %d", a[s], num[s], numOfnum(a[s]));
    return 0;
}