小编dev*_*dev的帖子

通过inode打开文件

知道它的inode是否可以打开文件?

ls -i /tmp/test/test.txt
529965 /tmp/test/test.txt
Run Code Online (Sandbox Code Playgroud)

我可以提供路径,inode(529965以上),我希望得到一个文件描述符.

linux filesystems stdio

7
推荐指数
2
解决办法
5345
查看次数

发送 GAP ACL L2CAP 数据包

要提供有关此问题的一些背景信息,请尝试测试 CVE-2020-0022。

不知道最后怎么触发。

写了这个发送分段ACL L2CAP数据包的代码,所以也许有人觉得它有用。

在您应该将 ACL MTU 更改为所需之前,即

hciconfig hci0 aclmtu 50:10
Run Code Online (Sandbox Code Playgroud)

下面还尝试更改连接 MTU,但我不确定它是否有效以及是否需要这样做。来自的响应不是零散的,认为上述将实现这一目标。

您可以在屏幕截图上看到它:

在此处输入图片说明

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
#include <bluetooth/l2cap.h>

// Functions
void usage(void);

// MAIN PART
int main(int argc, char *argv[])
{

    l2cap_cmd_hdr *cmd;
    struct sockaddr_l2 laddr, raddr;
    struct hci_dev_info di;
    char *buf, *remote_address = NULL;
    char payload1[] = "\x00\x40\x00\x04\x01\x04\x01\x01";
    char payload[] = "\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50" \
"\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60" \
"\x61\x62\x63\x64\x65\x66\x67\x68\x41\x42\x43\x44\x45\x46\x47\x48" \
"\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58" \
"\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66\x67\x68" \ …
Run Code Online (Sandbox Code Playgroud)

bluetooth hci l2cap

5
推荐指数
0
解决办法
1294
查看次数

execve() 与来自文件的重定向标准输入

想要将 stdin 重定向到 execve() 中的文件。所以程序应该像这样执行,我的意思是这就是我在 shell 中执行它的方式并且它的工作原理:

/opt/prog < in.txt
Run Code Online (Sandbox Code Playgroud)

下面是我写的代码,但它似乎不起作用。in.txt 是二进制文件,我想将其重定向到执行程序中的标准输入。

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>

int main(void)
{
    int fd[2];
    pid_t pid;


    FILE *f = fopen("in.txt", "rb");

    if (pipe(fd) < 0)
        return EXIT_FAILURE;

    if ((pid = fork()) < 0)
        return EXIT_FAILURE;
    else if (pid != 0) { /* father */
        close(fd[1]);
        dup2(fd[0], STDIN_FILENO);
        execlp("/opt/prog", "prog", (char *)0);
        printf("done\n");
    } else { /* son */

        fseek(f, 0, SEEK_END);
        long fsize …
Run Code Online (Sandbox Code Playgroud)

c linux stdin

4
推荐指数
1
解决办法
6672
查看次数

在汇编器 x64 中获取 argv[2] 地址

edi 是 argc,rsi 是 argv

   0x0000000000400535 <+8>: mov    %edi,-0x4(%rbp)
   0x0000000000400538 <+11>:    mov    %rsi,-0x10(%rbp)
Run Code Online (Sandbox Code Playgroud)

这里我得到argv指针

(gdb) x/8x $rbp-0x10
0x7ffdb7cac380: 0xb7cac478  0x00007ffd  0x00000000  0x00000003
0x7ffdb7cac390: 0x00000000  0x00000000  0x1f130b45  0x00007ff3
Run Code Online (Sandbox Code Playgroud)

指针0x7ffdb7cac478

所以我的 argv[2] 在这里:

(gdb) x/8x 0x7ffdb7cac478+16
0x7ffdb7cac488: 0xb7cacd8a  0x00007ffd  0x00000000  0x00000000
Run Code Online (Sandbox Code Playgroud)

地址 0x7ffdb7cacd8a

我需要获取argv[2]的地址,所以我想编写这个汇编代码:

伪代码:

x - 从地址 $rbp-0x10 //(指向 argv 的指针)加载 8 个字节

y - 从 x 值+16 加载 8 个字节 //(指向 argv[2] 的指针)

我需要稍后跳转到 y。

如何用 x64 汇编程序编写?我可以使用哪个寄存器来表示 x 和 y?

我希望这是可以理解的。我是初学者。

我在这里问是因为我不知道从哪里开始进行研究。

更新:

尝试过这个:

bits 64
ldr r8, rbp, …
Run Code Online (Sandbox Code Playgroud)

assembly

2
推荐指数
1
解决办法
2155
查看次数

如何在 Windows 10,11 上使用 CLI 或 Powershell 命令执行curl

想要在 Linux 下的 Bash 中找到与此等效的内容

sh <(curl https://sample.com/cli.sh)
Run Code Online (Sandbox Code Playgroud)

在 Windows CLI 或 Powershell 中

我知道Windows 中安装了curl。我怎样才能实现它?

有人会说这样不安全。我还将有一个带有 Windows Powershell 的 cli.ps1。

windows powershell curl invoke-webrequest

2
推荐指数
1
解决办法
5010
查看次数

使用Python中定义的元素值尽可能快地生成排列

尝试生成排列,可以与生成器一起使用或生成列表列表(但我可能需要大量内存?)在Internet和SO上查看,但找不到我为每个元素定义值的版本.

顺便说一下它会有多少种排列?

8个元素,每个值从1到15

这是我的代码,但也许有更好,更快的方法来生成它:

任何提示表示赞赏!

import time
from tqdm import tqdm
def permutations(iterable, r=None):
    # permutations('ABCD', 2) --> AB AC AD BA BC BD CA CB CD DA DB DC
    # permutations(range(3)) --> 012 021 102 120 201 210
    pool = tuple(iterable)
    n = len(pool)
    r = n if r is None else r
    if r > n:
        return
    indices = range(n)
    cycles = range(n, n-r, -1)
    yield tuple(pool[i] for i in indices[:r])
    while n:
        for i in reversed(range(r)):
            cycles[i] …
Run Code Online (Sandbox Code Playgroud)

python permutation

-3
推荐指数
1
解决办法
69
查看次数