小编use*_*694的帖子

C程序中的Shellcode

链接http://hackoftheday.securitytube.net/2013/04/demystifying-execve-shellcode-stack.html 突出显示了编写execve shellcode的方法.

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

unsigned char code[] = 
"\x31\xc0\x50\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3\x50\x89\xe2\x53\x89\xe1\xb0\x0b\xcd\x80";

main()
{

    printf("Shellcode Length: %d\n", strlen(code));

    int (*ret)() = (int(*)())code;

    ret();
}
Run Code Online (Sandbox Code Playgroud)

line int有int (*ret)() = (int(*)())code;什么作用?

c shellcode

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

-128和128 in 2的补码

在2的补码中,0-127表示为00000000到01111111.在负数的情况下,我们反转无符号表示中的所有位并加1以得到2的补码.

(参考:http://en.wikipedia.org/wiki/Signed_number_representations#Two.27s_complement)

因此,2的补码中的-1将是:


 unsigned 1 =      00000001

 invert all bits = 11111110

 add 1 =           11111111

但对于-128,如果我们遵循相同的步骤:


 unsigned 128 =    10000000

 invert all bits=  01111111

 add 1=            10000000

所以-128和128在2的补码表示法中具有相同的表示形式?为什么8位的2的补码范围不是-127到128?简而言之,为什么-128优先于使用相同位数表示无符号128?

binary twos-complement

10
推荐指数
2
解决办法
2万
查看次数

硬件如何运行组装?

我已经完成了编译器课程并自己制作了一个基础知识,我对第一个编译器仍然存在这种挥之不去的疑问.

从高级别到低级别,我看到运行的代码可以说是C或C++,它可以通过它的编译器转换为相应的汇编语言(比如说gcc).此代码依赖于平台(假设我在intel x86架构上).

现在问题是,硬件如何运行程序集?

我记得从我的计算机组织类中,每个汇编语句都转换为特定的格式(取决于处理器),例如,像mov ax,bx这样的语句被转换为它的操作码,比如0110 101010 101000.假设汇编程序解析我的汇编语言程序中的每个语句都将其转换为机器代码,那么第一个汇编程序是如何编写的?

assembly

8
推荐指数
2
解决办法
2519
查看次数

加密app/web.config文件中的自定义部分

我需要加密/解密app.config中的自定义部分以及web.config文件.我读到aspnet_regiis可用于web.config,但我需要以编程方式执行此操作.

打开mappedExeConfiguration后,我指定一个部分如下:

ConfigurationSection connStrings = config.AppSettings;
Run Code Online (Sandbox Code Playgroud)

加密/解密AppSettings部分.

如何指定自定义部分的名称?当我在configurationSection对象之后键入我的自定义部分的名称时,智能无法识别它.(它只识别一些众所周知的部分)

PS在我的函数中,我需要将自定义节名称作为字符串参数.

例:

例如

<Configuration>
   <MyCustomTag> 
       <... data /> 
   </MyCustomTag> 
 </Configuration>
Run Code Online (Sandbox Code Playgroud)

其中MyCustomTag是我需要加密/解密的部分.

c# encryption configuration-files

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

在C#中读取自定义配置节的键值

我需要从app/web.config中的自定义部分读取键值.

我经历了

使用ConfigurationManager从Web.Config中读取密钥

如何使用C#检索.config文件中的自定义配置节列表?

但是,当我们需要显式指定配置文件的路径时,它们没有指定如何读取自定义部分(在我的情况下,配置文件不在其默认位置)

我的web.config文件示例:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <MyCustomTag> 
    <add key="key1" value="value1" />
    <add key="key2" value="value2" />
  </MyCustomTag>
<system.web>
  <compilation related data />
 </system.web> 
</configuration>
Run Code Online (Sandbox Code Playgroud)

我需要在MyCustomTag中读取键值对.

当我尝试(configFilePath是我的配置文件的路径): -

var configFileMap = new ExeConfigurationFileMap { ExeConfigFilename = configFilePath };

var config =
          ConfigurationManager.OpenMappedExeConfiguration(
            configFileMap, ConfigurationUserLevel.None);

        ConfigurationSection section = config.GetSection(sectionName);

        return section[keyName].Value;
Run Code Online (Sandbox Code Playgroud)

我收到一条错误,指出"无法在[keyName]部分访问受保护的内部索引器'此'

c# configuration-files

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

通过软件NFC进行卡仿真

在阅读了很多问题之后,我决定发布这个问题.我读到android的股票版本不支持用于卡片仿真的API.此外,由于谷歌/三星管理的密钥,我们无法编写自定义应用程序来保护嵌入在nfc控制器中的元素.

我需要模仿一张牌(mifare或desfire等).我能看到的选项是通过软件来做.我有一个ACR122U阅读器,我已经测试过NFC P2P模式可以正常使用Nexus-S.

1)我遇到一个网站,说nexus的NFC控制器(pn532)可以模拟mifare 4k卡.如果这是真的,我可以写/读apdu命令到这个模拟卡吗?(可能如果我使用像cyanogenmod这样的模型rom)

2)我可以编写一个android应用程序来读取从阅读器发送的apdu命令并生成适当的响应(如果不完全,那么仅在某种程度上).为此,我搜索了我们需要使用cynagenmod修补nexus.有人尝试通过这种方法模拟卡吗?

我看到这是可能的,因为我们有来自访问控制公司的产品,提供可以打开门的移动应用程序,例如http://www.assaabloy.com/en/com/Products/seos-mobile-access/

android apdu nfc contactless-smartcard hce

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

realloc()无效的旧大小

我正在从KandR C编程书中做一些有趣的练习.该程序用于从用户输入的一组行中查找最长行,然后打印它.

这是我写的(部分,部分内容直接取自本书): -

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

int MAXLINE =  10;
int INCREMENT = 10;

void copy(char longest[], char line[]){
    int i=0;

    while((longest[i] = line[i]) != '\0'){
        ++i;
    }
}

int _getline(char s[]){
    int i,c;

    for(i=0; ((c=getchar())!=EOF && c!='\n'); i++){
        if(i == MAXLINE - 1){
            s = (char*)realloc(s,MAXLINE + INCREMENT);

            if(s == NULL){
                printf("%s","Unable to allocate memory");
                //  goto ADDNULL;
                exit(1);
            }

            MAXLINE = MAXLINE + INCREMENT;
        }
        s[i] = c;
    }

    if(c == '\n'){
        s[i] = c;
        ++i; …
Run Code Online (Sandbox Code Playgroud)

c realloc dynamic-memory-allocation

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

重写一个小的 execve shellcode

浏览http://hackoftheday.securitytube.net/2013/04/demystifying-execve-shellcode-stack.html

execve我理解了调用并试图重写它的nasm 程序。

一些背景信息:

int execve(const char *filename, char *const argv[], char *const envp[]);
Run Code Online (Sandbox Code Playgroud)

因此,eax = 11( 的函数调用号execve),ebx应该指向char* filenameecx应该指向argv[](这将与第一个参数相同,ebx因为第一个参数是其*filename本身,例如在本例中为“/bin/sh”),并且edx将指向envp[]null在本例中)。

原始nasm代码:

global _start

section .text
_start:

xor eax, eax
push eax

; PUSH //bin/sh in reverse i.e. hs/nib//

push 0x68732f6e
push 0x69622f2f

mov ebx, esp

push eax
mov edx, esp

push ebx
mov ecx, esp

mov al, …
Run Code Online (Sandbox Code Playgroud)

c++ assembly nasm execve shellcode

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

可寻址存储器以及与缓冲区溢出的关系

阅读缓冲区溢出,我遇到了下面给出的示例代码: -

void function(int a, int b, int c) {
char buffer1[5];
char buffer2[10];
}

void main() {
 function(1,2,3);
}
Run Code Online (Sandbox Code Playgroud)

这是来自着名的粉碎堆栈的乐趣和利润文章我猜.(参考:http://insecure.org/stf/smashstack.html)

文章说,要为buffer1和buffer2分配空间,需要20个字节(缓冲区1为8个字节,缓冲区2为12个字节),因为只能以字大小的倍数访问存储器地址(在这种情况下,1个字= 4个字节).

但我记得内存是字节可寻址的,即我可以从内存中一次访问1个字节.我将此与处理器的位数相关联.例如,32位处理器可以访问2 ^ 32个存储器位置,并且由于1个存储器位置保持1个字节(8位),因此32位处理器的总可寻址存储器等于(2 ^ 32)/(1024*1024*1024)= 4096 MB = 4GB.

因为在上面的例子中,buffer1和buffer2都是char类型,假设需要1个字节,为什么我们不能分别为buffer1和buffer2分配5个字节和10个字节?

为什么内存访问限制为字大小的倍数?

c memory-management buffer-overflow

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

sql server 的等效 jdbc 连接字符串

我当前正在使用以下连接字符串连接到数据库(数据库与 ServerIP 位于同一服务器上):

String constr = "Data Source=ServerIP,1433;Network Library=DBMSSOCN;Initial 
Catalog=dbName;User ID=dbUserID;Password=dbUserPassword";
Run Code Online (Sandbox Code Playgroud)

在 asp.net 中使用时连接良好。(我已经手动创建了 dbUserId 并从 sql server management studio 为其分配了 dbUserPassword。dbUserId 是数据库“dbName”的所有者)

我在另一台电脑上有一个 java swing 应用程序,我需要连接到同一个数据库。我正在使用位于 C: 中的 sqljdbc4.jar。我的类路径有条目“.;C:\sqljdbc4.jar”。为了完成连接,我使用以下代码行:

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

 String url = "jdbc:sqlserver://ServerIP:1433;databaseName=dbName";

   String user = "dbUserID";
   String pass = "dbUserPassword";
   Connection connection = DriverManager.getConnection(url, user, pass); 
Run Code Online (Sandbox Code Playgroud)

但是,我在“Connection connection =DriverManager.getConnection(url, user, pass);”行上遇到异常 :“与主机“ServerIP”端口 1433 的 TCP/IP 连接失败。错误:“连接超时。验证连接属性。确保 SQL Server 实例正在主机上运行并在端口上接受 TCP/IP 连接。确保到该端口的 TCP 连接没有被防火墙阻止。”

我已检查 Windows 防火墙是否已关闭(并且还为家庭和公共网络上的 MSSQLSERVER 端口 1433 tcp 添加了例外)。从 sql server management studio 中,我为 sql …

java sql asp.net jdbc

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