小编Goo*_*ies的帖子

使用DD递归写入特定文件

我有一个我要覆盖的硬盘驱动器,不是使用空字节,而是使用消息.

48 69 64 64 65 6e 20 ="隐藏"

到目前为止,这是我的命令:

echo "Hidden " > /myfile
dd if=/myfile of=/dev/sdb bs=1M
Run Code Online (Sandbox Code Playgroud)

注意:我也尝试过诸如count和conv之类的参数,但无济于事

现在,这很好.当我跑:

dd if=/dev/sdb | hexdump -C | less
Run Code Online (Sandbox Code Playgroud)

我可以看到写过的前几个字节,但其余的都没有改变.我想以递归方式将"隐藏"写入驱动器.

linux hdd computer-forensics dd drive

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

GDB“地址”。这些是什么?

这应该是一个非常简单、非常快速的问题。这些是 CI 中编写的程序的前 3 行:

Dump of assembler code for function main:
   0x0804844d <+0>: push   ebp
   0x0804844e <+1>: mov    ebp,esp
   0x08048450 <+3>: and    esp,0xfffffff0
   ... ... ... ... ... ... ...
Run Code Online (Sandbox Code Playgroud)

什么是0x0804844d和?它不受 ASLR 的影响。它仍然是内存地址,还是文件的相对点?0x0804844e0x08048450

memory assembly gdb memory-management

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

比较C中未排序数组值的优雅方法?

我在C中有两个int数组,我想比较它们.这是我非常快速的攻击,但我想知道是否有更快的方法.

1)找到一个不在我们正在比较的数组(arr2)中的整数.
2)复制原始数组(arr2).
3)迭代第一个数组(arr1),如果在复制的数组中找到元素,我们用我们知道的原始数组中的值替换该索引处的值(这是为了防止多个时的短路)相同值的值在数组中).

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <random.h>


bool isin(int arr[], int elem, size_t len, size_t *index) {
    int i;
    for (i = 0; i < len; ++i) {
        if (arr[i] == elem) {
            if(index != NULL)
                *index = i;
            return true;
        }
    }
    return false;
}

int notInArray(int arr[], size_t len) {
    int r;
    do {
        r = rand();
    } while (isin(arr, r, len, NULL));
    return r;
}

bool arraysEqual(int arr1[], int arr2[], size_t len) …
Run Code Online (Sandbox Code Playgroud)

c arrays

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

拖放文件名 Visual(托管)C++

我有一个 RichTextBox,我希望允许用户将文件从磁盘拖放到其中。文本框中应显示的只是文件名。此代码当前添加"System.String[]"到文本框而不是文件名。当我按照 MSDN 的建议更改为DataFormats::FileDrop,出现 NULL 取消引用错误。DataFormats::Text

RichTextBox 的名称是rtbFile。在我的构造函数中,我有:

this->rtbFile->AllowDrop = true;
Run Code Online (Sandbox Code Playgroud)

我设置了这样的事件(在InitializeComponents内):

this->rtbFile->DragEnter += gcnew System::Windows::Forms::DragEventHandler(this, &VanicheMain::rtbFile_DragEnter);
this->rtbFile->DragDrop += gcnew System::Windows::Forms::DragEventHandler(this, &VanicheMain::rtbFile_DragDrop);
Run Code Online (Sandbox Code Playgroud)

函数定义如下:

void rtbFile_DragEnter(System::Object ^sender, System::Windows::Forms::DragEventArgs ^ e) {
    if (e->Data->GetDataPresent(DataFormats::FileDrop))
        e->Effect = DragDropEffects::Copy;
    else
        e->Effect = DragDropEffects::None;
}

System::Void rtbFile_DragDrop(System::Object ^sender, System::Windows::Forms::DragEventArgs ^e){
    int i = rtbFile->SelectionStart;;
    String ^s = rtbFile->Text->Substring(i);
    rtbFile->Text = rtbFile->Text->Substring(0, i);
    String ^str = String::Concat(rtbFile->Text, e->Data->GetData(DataFormats::FileDrop)->ToString());
    rtbFile->Text = String::Concat(str, s);
}
Run Code Online (Sandbox Code Playgroud)

c++ drag-and-drop visual-studio visual-c++

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

为什么unordered_set比它包含的数据使用更多的RAM?

我有一个相对较大的文件,我需要确保只包含唯一的行.该文件只有500MB.我知道有很多开销,但我看到了近5GB的RAM使用率.我可以使用外部合并排序并保持少量RAM,但这似乎更快编码.

我正在使用VC++ 14.

#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <unordered_set>

using std::vector;
using std::string;
using std::unordered_set;

class uniqify {
    unordered_set<string> s;
public:
    auto exists(const string &filename) const -> bool {
        std::ifstream fin(filename);
        bool good = fin.good();
        return fin.close(), good;
    }

    void read(const string &filename) {
        std::ifstream input(filename);
        string line;
        while (std::getline(input, line))
            if (line.size())
                s.insert(line);
    }

    void write(const string &filename) const {
        std::ofstream fout(filename);
        for (auto line : s)
            fout << line << "\n";
        fout.close(); …
Run Code Online (Sandbox Code Playgroud)

c++ unordered-set c++11

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

Cython使用prange / parallel不会提高性能

我正在使用Cython版本0.27.3来编译以下简单源测试模块的源代码,该模块包含同一算法的python和cython实现。当我将threads参数设置为不同的值时,尽管释放了GIL,但我看不到性能提高。是否有某些东西阻止它并行运行?

有问题的函数是,cdef void _getprimes它接受memoryview切片作为参数,并且应将该切片中的所有非素数值都设置为0。

primes.pyx

#cython: boundscheck=False, wraparound=False, nonecheck=False
cimport cython
from cpython cimport array
from cython.parallel cimport parallel, prange
from libc.math cimport sqrt, ceil
from libc.stdlib cimport malloc, free
from libc.stdio cimport printf
import math

# =====================
# Python implementation
# =====================

def pyisprime(n):
    """Python implementation"""
    if n < 2 or n & 1 == 0:
        if n == 2:
            return True
        return False
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i …
Run Code Online (Sandbox Code Playgroud)

python performance multithreading cython

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

如何在全局变量中获得缓冲区溢出?

我正在研究检测和防止BOF攻击,我想知道,我怎样才能溢出全局结构?

我的代码:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

struct{
        char name[20];
        char description[10];
} test;


int main(int argc, char **argv){
        if(argc != 2)
                exit(-1);
        *(*(argv+1)+20) = '\x00'; //terminate string after 20 characters

        strcpy(test.name, argv[1]); //no BOF here... stopped at 20
        printf("%s\n", test.name);

        char *desc;
        desc = malloc(10);
        if(!desc){
                printf("Error allocating memory\n");
                exit(-1);
        }
        scanf("%s", desc); //no bounds checking - this is where I BOF
        strcpy(test.description, desc); //copy over 10 characters into 10 char buffer
        printf("%s\n", test.description); //this prints out whatever …
Run Code Online (Sandbox Code Playgroud)

c buffer global-variables buffer-overflow

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

从模板类中提取typedef/using定义

有没有办法从模板类中提取typedef?例如,这就是我想要做的:

template<typename T, typename... Args>
class Foo{
public:
   typedef T(*Functor)(Args...);
   Foo() = default;
};

template<typename T, typename... Args>
Foo<T, Args...> make_foo(T(*f)(Args...)){
    return Foo<T, Args...>;
}

int bar(int i){
    return i * 2;
}

using type = make_foo(bar)::Functor;
Run Code Online (Sandbox Code Playgroud)

我不能做到这一点.但是,我可以这样做:

using type = Foo<int, int>::Functor;
Run Code Online (Sandbox Code Playgroud)

这种打败了我的目的.有没有办法包装一个函数,以便我可以以类型形式提取它?

c++ templates types casting

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

PyQt5非默认参数后默认参数?

我在GUI方面没有做很多工作,但是我决定从偶尔使用PyQt4转到PyQt5。我的IDE给我有关某些__init__功能的警告,尤其是QWidget和QMainWindow。

如果查看IntelliSense的参数,则会看到该parent参数具有默认值,而flags没有默认值。IDE会告诉我flags未填充的内容,但是当我不提供它时,什么也不会发生。为什么会这样呢?

我正在使用Python 3.5。

没有

python pyqt5

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