strcat溢出?(strcat overflow?)
有人可以解释为什么我的strcat这样做?
我似乎无法找出为什么我要重写源字符串的一部分。
输出如下:New String:HelloThis应该在str1中str1h 0中的反斜杠0之后
global strcat extern strlen
strcat的:
push ebp mov ebp, esp push ecx push esi push edi push ebx push edx xor edx, edx xor edi, edi xor ebx, ebx xor esi, esi xor ecx, ecx mov edi, [ebp + 8] mov esi, [ebp + 12] push edi call strlen pop edi mov ecx, eax xor eax, eax push esi call strlen pop esi mov ebx, eax xor eax, eax cmp [edi + ecx], byte 0b je PUT_LINE jmp FINALIZE_END
PUT_LINE:
cmp ebx, eax je END mov dl, [esi + eax] mov [edi + ecx], dl xor edx, edx inc eax inc ecx jmp PUT_LINE
结束:
mov eax, [ebp + 8] jmp FINALIZE_END
FINALIZE_END:
pop edx pop ebx pop edi pop esi pop ecx mov esp, ebp pop ebp ret
〜
〜
int main(int argc, char** argv) { (void)argc; (void)argv; char* str1; char* str2; str1 = strdup("Hello"); str2 = strdup("This shall be after my backslash 0 in str1"); printf("New String : %s\n", strcat(str1, str2)); return (0); }
〜
Could someone explain why is my strcat doing this?
I can't seem to find out why I am rewriting on a part of the source string.
The output is like this: New String: HelloThis shall be after my backslash 0 in str1h 0 in str1
global strcat extern strlen
strcat:
push ebp mov ebp, esp push ecx push esi push edi push ebx push edx xor edx, edx xor edi, edi xor ebx, ebx xor esi, esi xor ecx, ecx mov edi, [ebp + 8] mov esi, [ebp + 12] push edi call strlen pop edi mov ecx, eax xor eax, eax push esi call strlen pop esi mov ebx, eax xor eax, eax cmp [edi + ecx], byte 0b je PUT_LINE jmp FINALIZE_END
PUT_LINE:
cmp ebx, eax je END mov dl, [esi + eax] mov [edi + ecx], dl xor edx, edx inc eax inc ecx jmp PUT_LINE
END:
mov eax, [ebp + 8] jmp FINALIZE_END
FINALIZE_END:
pop edx pop ebx pop edi pop esi pop ecx mov esp, ebp pop ebp ret
~
~
int main(int argc, char** argv) { (void)argc; (void)argv; char* str1; char* str2; str1 = strdup("Hello"); str2 = strdup("This shall be after my backslash 0 in str1"); printf("New String : %s\n", strcat(str1, str2)); return (0); }
~
原文:https://stackoverflow.com/questions/9646414
更新时间:2024-02-01 08:02
最满意答案
您可以继承
WWW::Mechanize
并重新定义get()
方法来执行您想要的操作:package MyMech; use base 'WWW::Mechanize'; sub get { my $self = shift; my($url) = @_; if (defined $self->res && $self->res->request->uri ne $url) { return $self->SUPER::get(@_) } return $self->res; }
You can subclass
WWW::Mechanize
and redefine theget()
method to do what you want:package MyMech; use base 'WWW::Mechanize'; sub get { my $self = shift; my($url) = @_; if (defined $self->res && $self->res->request->uri ne $url) { return $self->SUPER::get(@_) } return $self->res; }
相关问答
更多-
通常, WWW::Mechanize 并不总是在MSWin32上传递所有测试 。 如果你只有一个失败的测试,我会计算我的祝福并强制安装它。 In general WWW::Mechanize doesn't always pass all of its tests on MSWin32. If you only got one failed test, I would count my blessings and force install it.
-
您需要在您的网址前加上$dir 。 而不是使用follow_link()您指定URL的follow_link() ,只需使用另一个get() : $mech->get( "file:$dir/" . $link->url() ); You need to prepend $dir to your URL. Instead of using follow_link(), which won't let you specify the URL, simply use another get(): $mech- ...
-
为什么WWW :: Mechanize获取某些页面而不是其他页面?(Why does WWW::Mechanize GET certain pages but not others?)[2022-10-27]
这是因为维基百科拒绝访问基于请求上提供的用户代理的一些程序。 通过在实例化之后和get()之前设置代理,您可以将自己别名为“普通”Web浏览器,例如: $mech->agent( 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.17.8 (KHTML, like Gecko) Version/5.0.1 Safari/533.17.8' ); 这对我来说在你发布的URL中起作用。 较短的字符串可能也会起作用 ... -
您可以继承WWW::Mechanize并重新定义get()方法来执行您想要的操作: package MyMech; use base 'WWW::Mechanize'; sub get { my $self = shift; my($url) = @_; if (defined $self->res && $self->res->request->uri ne $url) { return $self->SUPER::get(@_) } retur ...
-
当您的用户代理没有做您认为应该做的事情时,请将其请求与交互式浏览器的请求进行比较。 Firefox插件对于这类事情很方便。 您可能遗漏了服务器期望的部分进程。 您可能没有正确登录或交互,这可能是出于各种原因。 例如,页面上可能存在WWW :: Mechanize未处理的 JavaScript。 当您可以确定交互式浏览器正在执行的操作时,您将知道在何处需要改进脚本。 在您的脚本中,您还可以通过打开LWP中的调试来观察正在发生的事情,其中构建了Mech: use LWP::Debug qw(+); rjh ...
-
解决方案是更改util.rb中的第40行 Iconv.iconv(code, "UTF-8", s).join("") 至 Iconv.iconv("#{code}//IGNORE", "UTF-8", s).join("") 要么 Iconv.conv("#{code}//IGNORE", "UTF-8", s) The solution is to change line 40 in util.rb from Iconv.iconv(code, "UTF-8", s).join("") to I ...
-
使用driver =>'Memory',缓存不会保留在磁盘上 - 将驱动程序更改为'File'或磁盘上的其他内容。 With driver => 'Memory', the cache won't persist on disk -- change the driver to 'File' or something else that's on disk.
-
WWW :: Mechanize:如何以不同的文件名上传文件?(WWW::Mechanize : How to upload file under different file name?)[2022-07-22]
my $file = [ 'filename-on-disk.txt', # The file you'd like to upload. 'filename-for-upload.txt', # The filename you'd like to give the web server. 'Content-type' => 'text/plain' # Any other flags you'd like to add go here. ]; $mech->post("http ... -
问题是html不包含8021x_mode的选择。 我收到此错误: 没有为Checkbox发现名称为'8021x_mode'且在test.pl第24行的值为'any'的元素。 要检查表单,我建议您使用mech-dump实用程序(与WWW::Mechanize一起安装) $ mech-dump --forms http://domain.tld/path_to_forms POST /goform/FormUpdateVAP [myform] essid=X ( ...
-
对于LWP :: UserAgent和WWW :: Mechanize,都没有记录agent_alias参数。 而且也没有agent_alias参数实现。 相反, 在两种情况下都会忽略该参数 ,并使用内置默认值 。 但默认是不同的 。 对于WWW :: Mechanize,有一个agent_alias 方法 。 从文档 : ...例如, $mech->agent_alias( 'Windows IE 6' ); 将您的用户代理设置为 Mozilla/4.0 (compatible; MSIE 6.0; W ...