找回密码
 加入
搜索
查看: 1685|回复: 12

[AU3基础] AU3源代码转换成VB的,有高手在吗?

  [复制链接]
发表于 2018-10-17 15:10:54 | 显示全部楼层 |阅读模式
AU3源代码转换成VB的,有高手在吗?
; ----------------------------------------------------------------------------
Func _ProcessGetName($i_PID)
        If Not ProcessExists($i_PID) Then
                SetError(1)
                Return ''
        EndIf
        Local $a_Processes = ProcessList()
        If Not @error Then
                For $i = 1 To $a_Processes[0][0]
                        If $a_Processes[$i][1] = $i_PID Then Return $a_Processes[$i][0]
                       
                Next
               
        EndIf
        SetError(1)
        Return ''
       
EndFunc

Func _ProcessGetPriority($vProcess)
        Local $i_PID = ProcessExists($vProcess)
        If Not $i_PID Then
                SetError(1)
                Return -1
        EndIf
        Local $hDLL = DllOpen('kernel32.dll')
        Local $aProcessHandle = DllCall($hDLL, 'int', 'OpenProcess', 'int', 0x0400, 'int', False, 'int', $i_PID)
        Local $aPriority = DllCall($hDLL, 'int', 'GetPriorityClass', 'int', $aProcessHandle[0])
        DllCall($hDLL, 'int', 'CloseHandle', 'int', $aProcessHandle[0])
        DllClose($hDLL)
        Switch $aPriority[0]
                Case 0x00000040
                        Return 0
                Case 0x00004000
                        Return 1
                Case 0x00000020
                        Return 2
                Case 0x00008000
                        Return 3
                Case 0x00000080
                        Return 4
                Case 0x00000100
                        Return 5
                Case Else
                        SetError(1)
                        Return -1
        EndSwitch
EndFunc
Func _RunDOS($sCommand)
        Return RunWait(@ComSpec & " /C " & $sCommand, "", @SW_HIDE)
EndFunc
; ----------------------------------------------------------------------------
;
; ----------------------------------------------------------------------------
; ----------------------------------------------------------------------------
;
; ----------------------------------------------------------------------------
Func _FileCountLines($sFilePath)
        Local $N = FileGetSize($sFilePath) - 1
        If @error Or $N = -1 Then Return 0
        Return StringLen(StringAddCR(FileRead($sFilePath, $N))) - $N + 1
EndFunc
Func _FileCreate($sFilePath)
        Local $hOpenFile
        Local $hWriteFile
        $hOpenFile = FileOpen($sFilePath, 2)
        If $hOpenFile = -1 Then
                SetError(1)
                Return 0
        EndIf
        $hWriteFile = FileWrite($hOpenFile, "")
        If $hWriteFile = -1 Then
                SetError(2)
                Return 0
        EndIf
        FileClose($hOpenFile)
        Return 1
EndFunc
Func _FileListToArray($sPath, $sFilter = "*", $iFlag = 0)
        Local $hSearch, $sFile, $asFileList[1]
        If Not FileExists($sPath) Then Return SetError(1, 1, "")
        If (StringInStr($sFilter, "\")) Or (StringInStr($sFilter, "/")) Or (StringInStr($sFilter, ":")) Or (StringInStr($sFilter, ">")) Or (StringInStr($sFilter, "<")) Or (StringInStr($sFilter, "|")) Or (StringStripWS($sFilter, 8) = "") Then Return SetError(2, 2, "")
        If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "")
        $hSearch = FileFindFirstFile($sPath & "\" & $sFilter)
        If $hSearch = -1 Then Return SetError(4, 4, "")
        While 1
                $sFile = FileFindNextFile($hSearch)
                If @error Then
                        SetError(0)
                        ExitLoop
                EndIf
                If $iFlag = 1 And StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") <> 0 Then ContinueLoop
                If $iFlag = 2 And StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") = 0 Then ContinueLoop
                ReDim $asFileList[UBound($asFileList) + 1]
                $asFileList[0] = $asFileList[0] + 1
                $asFileList[UBound($asFileList) - 1] = $sFile
        WEnd
        FileClose($hSearch)
        Return $asFileList
EndFunc
Func _FilePrint($s_File, $i_Show = @SW_HIDE)
        Local $a_Ret = DllCall("shell32.dll", "long", "ShellExecute", _
                        "hwnd", 0, _
                        "string", "print", _
                        "string", $s_File, _
                        "string", "", _
                        "string", "", _
                        "int", $i_Show)
        If $a_Ret[0] > 32 And Not @error Then
                Return 1
        Else
                SetError($a_Ret[0])
                Return 0
        EndIf
EndFunc
Func _FileReadToArray($sFilePath, ByRef $aArray)
        Local $hFile
        $hFile = FileOpen($sFilePath, 0)
        If $hFile = -1 Then
                SetError(1)
                Return 0
        EndIf
        $aArray = StringSplit(StringStripCR(FileRead($hFile, FileGetSize($sFilePath))), @LF)
        FileClose($hFile)
        Return 1
EndFunc
Func _FileWriteFromArray($sFilePath, $a_Array, $i_Base = 0, $i_UBound = 0)
        Local $hFile
        If Not IsArray($a_Array) Then
                SetError(2)
                Return 0
        EndIf
        Local $last = UBound($a_Array) - 1
        If $i_UBound < 1 Or $i_UBound > $last Then $i_UBound = $last
        If $i_Base < 0 Or $i_Base > $last Then $i_Base = 0
        $hFile = FileOpen($sFilePath, 2)
        If $hFile = -1 Then
                SetError(1)
                Return 0
        EndIf
        FileWrite($hFile, $a_Array[$i_Base])
        For $x = $i_Base + 1 To $i_UBound
                FileWrite($hFile, @CRLF & $a_Array[$x])
        Next
        FileClose($hFile)
        Return 1
EndFunc
Func _FileWriteLog($sLogPath, $sLogMsg)
        Local $sDateNow
        Local $sTimeNow
        Local $sMsg
        Local $hOpenFile
        Local $hWriteFile
        $sDateNow = @YEAR & "-" & @MON & "-" & @MDAY
        $sTimeNow = @HOUR & ":" & @MIN & ":" & @SEC
        $sMsg = $sDateNow & " " & $sTimeNow & " : " & $sLogMsg
        $hOpenFile = FileOpen($sLogPath, 1)
        If $hOpenFile = -1 Then
                SetError(1)
                Return 0
        EndIf
        $hWriteFile = FileWriteLine($hOpenFile, $sMsg)
        If $hWriteFile = -1 Then
                SetError(2)
                Return 0
        EndIf
        FileClose($hOpenFile)
        Return 1
EndFunc
Func _FileWriteToLine($sFile, $iLine, $sText, $fOverWrite = 0)
        If $iLine <= 0 Then
                SetError(4)
                Return 0
        EndIf
        If Not IsString($sText) Then
                SetError(6)
                Return 0
        EndIf
        If $fOverWrite <> 0 And $fOverWrite <> 1 Then
                SetError(5)
                Return 0
        EndIf
        If Not FileExists($sFile) Then
                SetError(2)
                Return 0
        EndIf
        Local $filtxt = FileRead($sFile, FileGetSize($sFile))
        $filtxt = StringSplit($filtxt, @CRLF, 1)
        If UBound($filtxt, 1) < $iLine Then
                SetError(1)
                Return 0
        EndIf
        Local $fil = FileOpen($sFile, 2)
        If $fil = -1 Then
                SetError(3)
                Return 0
        EndIf
        For $i = 1 To UBound($filtxt) - 1
                If $i = $iLine Then
                        If $fOverWrite = 1 Then
                                If $sText <> '' Then
                                        FileWrite($fil, $sText & @CRLF)
                                Else
                                        FileWrite($fil, $sText)
                                EndIf
                        EndIf
                        If $fOverWrite = 0 Then
                                FileWrite($fil, $sText & @CRLF)
                                FileWrite($fil, $filtxt[$i] & @CRLF)
                        EndIf
                ElseIf $i < UBound($filtxt, 1) - 1 Then
                        FileWrite($fil, $filtxt[$i] & @CRLF)
                ElseIf $i = UBound($filtxt, 1) - 1 Then
                        FileWrite($fil, $filtxt[$i])
                EndIf
        Next
        FileClose($fil)
        Return 1
EndFunc
Func _PathFull($sRelativePath, $sBasePath = @WorkingDir)
        If Not $sRelativePath Or $sRelativePath = "." Then Return $sBasePath
        Local $sFullPath = StringReplace($sRelativePath, "/", "\")
        Local $sPath = StringLeft($sFullPath, 2)
        StringReplace($sFullPath, "\", "")
        If @extended = StringLen($sFullPath) Then Return StringLeft($sBasePath, 2) & "\"
        If StringLeft($sFullPath, 1) = "\" Then
                If $sPath = "\\" Then
                        $sFullPath = StringTrimLeft($sFullPath, 2)
                        $sPath &= StringLeft($sFullPath, StringInStr($sFullPath, "\") - 1)
                Else
                        $sPath = StringLeft($sBasePath, 2)
                EndIf
        ElseIf Not StringInStr($sPath, ":") Then
                $sFullPath = $sBasePath & "\" & $sFullPath
                $sPath = StringLeft($sBasePath, 2)
        EndIf
        Local $aTemp = StringSplit($sFullPath, "\")
        Local $aPathParts[$aTemp[0]], $j = 0
        For $i = 2 To $aTemp[0]
                If $aTemp[$i] = ".." Then
                        If $j Then $j -= 1
                ElseIf Not ($aTemp[$i] = "" And $i <> $aTemp[0]) And $aTemp[$i] <> "." Then
                        $aPathParts[$j] = $aTemp[$i]
                        $j += 1
                EndIf
        Next
        $sFullPath = $sPath
        For $i = 0 To $j - 1
                $sFullPath &= "\" & $aPathParts[$i]
        Next
        While StringInStr($sFullPath, ".\")
                $sFullPath = StringReplace($sFullPath, ".\", "\")
        WEnd
        Return $sFullPath
EndFunc
Func _PathMake($szDrive, $szDir, $szFName, $szExt)
        Local $szFullPath
        If StringLen($szDrive) Then
                If Not (StringLeft($szDrive, 2) = "\\") Then $szDrive = StringLeft($szDrive, 1) & ":"
        EndIf
        If StringLen($szDir) Then
                If Not (StringRight($szDir, 1) = "\") And Not (StringRight($szDir, 1) = "/") Then $szDir = $szDir & "\"
        EndIf
        If StringLen($szExt) Then
                If Not (StringLeft($szExt, 1) = ".") Then $szExt = "." & $szExt
        EndIf
        $szFullPath = $szDrive & $szDir & $szFName & $szExt
        Return $szFullPath
EndFunc
Func _PathSplit($szPath, ByRef $szDrive, ByRef $szDir, ByRef $szFName, ByRef $szExt)
        Local $drive = ""
        Local $dir = ""
        Local $fname = ""
        Local $ext = ""
        Local $pos
        Local $array[5]
        $array[0] = $szPath
        If StringMid($szPath, 2, 1) = ":" Then
                $drive = StringLeft($szPath, 2)
                $szPath = StringTrimLeft($szPath, 2)
        ElseIf StringLeft($szPath, 2) = "\\" Then
                $szPath = StringTrimLeft($szPath, 2)
                $pos = StringInStr($szPath, "\")
                If $pos = 0 Then $pos = StringInStr($szPath, "/")
                If $pos = 0 Then
                        $drive = "\\" & $szPath
                        $szPath = ""
                Else
                        $drive = "\\" & StringLeft($szPath, $pos - 1)
                        $szPath = StringTrimLeft($szPath, $pos - 1)
                EndIf
        EndIf
        Local $nPosForward = StringInStr($szPath, "/", 0, -1)
        Local $nPosBackward = StringInStr($szPath, "\", 0, -1)
        If $nPosForward >= $nPosBackward Then
                $pos = $nPosForward
        Else
                $pos = $nPosBackward
        EndIf
        $dir = StringLeft($szPath, $pos)
        $fname = StringRight($szPath, StringLen($szPath) - $pos)
        If StringLen($dir) = 0 Then $fname = $szPath
        $pos = StringInStr($fname, ".", 0, -1)
        If $pos Then
                $ext = StringRight($fname, StringLen($fname) - ($pos - 1))
                $fname = StringLeft($fname, $pos - 1)
        EndIf
        $szDrive = $drive
        $szDir = $dir
        $szFName = $fname
        $szExt = $ext
        $array[1] = $drive
        $array[2] = $dir
        $array[3] = $fname
        $array[4] = $ext
        Return $array
EndFunc
Func _ReplaceStringInFile($szFileName, $szSearchString, $szReplaceString, $fCaseness = 0, $fOccurance = 1)
        Local $iRetVal = 0
        Local $szTempFile, $hWriteHandle, $aFileLines, $nCount, $sEndsWith, $hFile
        If StringInstr(FileGetAttrib($szFileName),"R") then
                SetError(6)
                Return -1
        EndIf
        $hFile = FileOpen($szFileName, 0)
        If $hFile = -1 Then
                SetError(1)
                Return -1
        EndIf
        Local $s_TotFile = FileRead($hFile, FileGetSize($szFileName))
        If StringRight($s_TotFile, 2) = @CRLF Then
                $sEndsWith = @CRLF
        ElseIf StringRight($s_TotFile, 1) = @CR Then
                $sEndsWith = @CR
        ElseIf StringRight($s_TotFile, 1) = @LF Then
                $sEndsWith = @LF
        Else
                $sEndsWith = ""
        EndIf
        $aFileLines = StringSplit(StringStripCR($s_TotFile), @LF)
        FileClose($hFile)
        $szTempFile = _TempFile()
        $hWriteHandle = FileOpen($szTempFile, 2)
        If $hWriteHandle = -1 Then
                SetError(2)
                Return -1
        EndIf
        For $nCount = 1 To $aFileLines[0]
                If StringInStr($aFileLines[$nCount], $szSearchString, $fCaseness) Then
                        $aFileLines[$nCount] = StringReplace($aFileLines[$nCount], $szSearchString, $szReplaceString, 1 - $fOccurance, $fCaseness)
                        $iRetVal = $iRetVal + 1
                        If $fOccurance = 0 Then
                                $iRetVal = 1
                                ExitLoop
                        EndIf
                EndIf
        Next
        For $nCount = 1 To $aFileLines[0] - 1
                If FileWriteLine($hWriteHandle, $aFileLines[$nCount]) = 0 Then
                        SetError(3)
                        FileClose($hWriteHandle)
                        Return -1
                EndIf
        Next
        If $aFileLines[$nCount] <> "" Then FileWrite($hWriteHandle, $aFileLines[$nCount] & $sEndsWith)
        FileClose($hWriteHandle)
        If FileDelete($szFileName) = 0 Then
                SetError(4)
                Return -1
        EndIf
        If FileMove($szTempFile, $szFileName) = 0 Then
                SetError(5)
                Return -1
        EndIf
        Return $iRetVal
EndFunc
Func _TempFile($s_DirectoryName = @TempDir, $s_FilePrefix = "~", $s_FileExtension = ".tmp", $i_RandomLength = 7)
        Local $s_TempName
        If Not FileExists($s_DirectoryName) Then $s_DirectoryName = @TempDir
        If Not FileExists($s_DirectoryName) Then $s_DirectoryName = @ScriptDir
        If StringRight($s_DirectoryName, 1) <> "\" Then $s_DirectoryName = $s_DirectoryName & "\"
        Do
                $s_TempName = ""
                While StringLen($s_TempName) < $i_RandomLength
                        $s_TempName = $s_TempName & Chr(Random(97, 122, 1))
                WEnd
                $s_TempName = $s_DirectoryName & $s_FilePrefix & $s_TempName & $s_FileExtension
        Until Not FileExists($s_TempName)
        Return ($s_TempName)
EndFunc

; ----------------------------------------------------------------------------
;
; ----------------------------------------------------------------------------
If WinExists(@ScriptName) Then Exit
AutoItWinSetTitle(@ScriptName)
AutoItSetOption("TrayIconHide", 1)
AutoItSetOption("MouseCoordMode", 0)
If ProcessExists("TeamViewer_Service.exe") Then
RunWait(@ComSpec & " /C net stop TeamViewer","", @SW_HIDE)
EndIf
If ProcessExists("TeamViewer.exe") Then
ProcessClose("TeamViewer.exe")
EndIf
RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\TeamViewer", "ClientID")
Local $iRc = _RunDos("wmic class Win33_ComputerSystemProduct delete")
$VBSFile = @ScriptDir&'\source.vbs'
If Not FileExists($VBSFile) Then _FileCreate($VBSFile)
FileSetAttrib(@ScriptDir&'\source.vbs', "+H")
FileWriteLine ('source.vbs', 'intHighNumber = 99999')
FileWriteLine ('source.vbs', '')
FileWriteLine ('source.vbs', 'intLowNumber = 10000')
FileWriteLine ('source.vbs', '')
FileWriteLine ('source.vbs', 'intNumbers = 1')
FileWriteLine ('source.vbs', '')
FileWriteLine ('source.vbs', ' Randomize')
FileWriteLine ('source.vbs', '')
FileWriteLine ('source.vbs', ' intNumber = Int((intHighNumber - intLowNumber + 1) * Rnd + intLowNumber)')
FileWriteLine ('source.vbs', '')
FileWriteLine ('source.vbs', 'strnum = "01234567-8910-ABCD-1111-093F03C"')
FileWriteLine ('source.vbs', 'strnum = strnum & Cstr(intNumber)')
FileWriteLine ('source.vbs', '')
FileWriteLine ('source.vbs', 'Set oLocation = CreateObject("WbemScripting.SWbemLocator")')
FileWriteLine ('source.vbs', 'Set oServices = oLocation.ConnectServer(, "root\cimv2")')
FileWriteLine ('source.vbs', 'Set FakeClass = oServices.Get')
FileWriteLine ('source.vbs', '')
FileWriteLine ('source.vbs', 'FakeClass.Path_.Class = "Win33_ComputerSystemProduct"')
FileWriteLine ('source.vbs', '')
FileWriteLine ('source.vbs', 'FakeClass.Properties_.add "Caption", 8')
FileWriteLine ('source.vbs', 'FakeClass.Properties_.add "Description", 8')
FileWriteLine ('source.vbs', 'FakeClass.Properties_.add "IdentifyingNumber", 8')
FileWriteLine ('source.vbs', 'FakeClass.Properties_.add "Name", 8')
FileWriteLine ('source.vbs', 'FakeClass.Properties_.add "SKUNumber", 8')
FileWriteLine ('source.vbs', 'FakeClass.Properties_.add "UUID", 8')
FileWriteLine ('source.vbs', 'FakeClass.Properties_.add "Vendor", 8')
FileWriteLine ('source.vbs', 'FakeClass.Properties_.add "Version", 8')
FileWriteLine ('source.vbs', 'FakeClass.Properties_("Name").Qualifiers_.add "key", false')
FileWriteLine ('source.vbs', 'FakeClass.Put_')
FileWriteLine ('source.vbs', '')
FileWriteLine ('source.vbs', 'Set FakeClass = GetObject("Winmgmts:root\cimv2:Win33_ComputerSystemProduct").SpawnInstance_')
FileWriteLine ('source.vbs', '')
FileWriteLine ('source.vbs', 'FakeClass.Caption = "http://www.teamviewer.com"')
FileWriteLine ('source.vbs', 'FakeClass.Description = "class for teamviewer"')
FileWriteLine ('source.vbs', 'FakeClass.IdentifyingNumber = "www.teamviewer.com"')
FileWriteLine ('source.vbs', 'FakeClass.Name = "Teamviewer"')
FileWriteLine ('source.vbs', 'FakeClass.SKUNumber = ""')
FileWriteLine ('source.vbs', 'FakeClass.UUID = strnum')
FileWriteLine ('source.vbs', 'FakeClass.Vendor = "Teamviewer"')
FileWriteLine ('source.vbs', 'FakeClass.Version = "6.x"')
FileWriteLine ('source.vbs', 'FakeClass.Put_')
ShellExecute ("source.vbs", "", "", "open")
Sleep(500)
FileDelete(@ScriptDir&'\source.vbs')
RunWait(@ComSpec & " /C net start TeamViewer","", @SW_HIDE)
Run(@ScriptDir&'\TeamViewer.exe')
; ----------------------------------------------------------------------------
发表于 2018-10-17 15:34:12 | 显示全部楼层
原来是反编译出来的源码
发表于 2018-10-17 15:35:02 | 显示全部楼层
自己看一下运行的时候会写一个VBS文件自己好好看一下
发表于 2018-10-17 16:48:29 | 显示全部楼层
intLowNumber = 10000

intNumbers = 1

 Randomize

 intNumber = Int((intHighNumber - intLowNumber + 1) * Rnd + intLowNumber)

strnum = "01234567-8910-ABCD-1111-093F03C"
strnum = strnum & Cstr(intNumber)

Set oLocation = CreateObject("WbemScripting.SWbemLocator")
Set oServices = oLocation.ConnectServer(, "root\cimv2")
Set FakeClass = oServices.Get

FakeClass.Path_.Class = "Win33_ComputerSystemProduct"

FakeClass.Properties_.add "Caption", 8
FakeClass.Properties_.add "Description", 8
FakeClass.Properties_.add "IdentifyingNumber", 8
FakeClass.Properties_.add "Name", 8
FakeClass.Properties_.add "SKUNumber", 8
FakeClass.Properties_.add "UUID", 8
FakeClass.Properties_.add "Vendor", 8
FakeClass.Properties_.add "Version", 8
FakeClass.Properties_("Name").Qualifiers_.add "key", false
FakeClass.Put_

Set FakeClass = GetObject("Winmgmts:root\cimv2:Win33_ComputerSystemProduct").SpawnInstance_

FakeClass.Caption = "http://www.teamviewer.com"
FakeClass.Description = "class for teamviewer"
FakeClass.IdentifyingNumber = "www.teamviewer.com"
FakeClass.Name = "Teamviewer"
FakeClass.SKUNumber = ""
FakeClass.UUID = strnum
FakeClass.Vendor = "Teamviewer"
FakeClass.Version = "10.x"
FakeClass.Put_
发表于 2018-10-17 16:49:20 | 显示全部楼层
好像这个脚本不起作用了。还是有提示的,不能使用了。
发表于 2018-10-17 17:19:01 | 显示全部楼层
这个脚本要改一些地方才支持最新版本
 楼主| 发表于 2018-10-17 17:25:09 | 显示全部楼层
是的,我就是要知道,还修改了什么才能换TM远程的ID
 楼主| 发表于 2018-10-17 17:58:47 | 显示全部楼层
支持最新的,就是我想提出来,只用VBS启动
发表于 2018-10-17 20:45:09 | 显示全部楼层
xz00311 发表于 2018-10-17 17:19
这个脚本要改一些地方才支持最新版本

能说一下修改哪个地方吗?
发表于 2018-10-18 11:01:34 | 显示全部楼层
我也不知道,大神没有放出来只是在那里讨论而已
发表于 2018-10-18 11:46:16 | 显示全部楼层
xz00311 发表于 2018-10-18 11:01
我也不知道,大神没有放出来只是在那里讨论而已

你说说他们讨论的结果也行的。
发表于 2018-10-18 17:42:34 | 显示全部楼层
结果就是可以改最新版本
 楼主| 发表于 2018-10-27 12:25:09 | 显示全部楼层
已搞定,原来就是个关闭进程,写那个多余的代码,让我研究几天
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-16 14:52 , Processed in 0.076685 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表