Advertisement
Najeebsk

NCMD.hta

Nov 29th, 2021
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 6.97 KB | None | 0 0
  1. <html>
  2. <title>Execution of command line with HTA by © Najeeb © 2021</title>
  3. <head>
  4. <HTA:APPLICATION
  5.     APPLICATIONNAME="Execution of command line with HTA by © Najeeb © 2021"
  6.     SCROLL="no"
  7.     SINGLEINSTANCE="yes"
  8.     WINDOWSTATE="maximize"
  9.     ICON="N2.ico";"N.ico";"Winver.exe"
  10. />
  11. </head>
  12. <META HTTP-EQUIV="MSThemeCompatible" CONTENT="YES">
  13. <script language="VBScript">
  14. Option Explicit
  15. Dim Title : Title = "Execution of command line with HTA by © Najeeb © 2021"
  16. '**********************************************************************************************
  17. Sub Window_OnLoad
  18.     Call Run_Cmd("help")
  19. End Sub
  20. '**********************************************************************************************
  21. Sub Run_Cmd(strCommand)
  22. On Error Resume Next
  23.     If input.value = "" Then
  24.         MsgBox "ATTENTION ! The text box is empty !"& vbcr &_
  25.        "You forgot to type a command on the text box !",vbExclamation,Title
  26.        input.value = "help"
  27.        Exit Sub
  28.    End if
  29.    Output.value = ""
  30.    btnClick.disabled = True
  31.    document.body.style.cursor = "wait"
  32.    btnClick.style.cursor = "wait"
  33.    Const ForReading = 1
  34.    Const TristateTrue = -1
  35.    Const TemporaryFolder = 2
  36.    Const WshHide = 0
  37.    Dim wsh, fs, ts
  38.    Dim strTempFile,strFile, strData
  39.    Set wsh = CreateObject("Wscript.Shell")
  40.    Set fs = CreateObject("Scripting.FileSystemObject")
  41.    strTempFile = fs.BuildPath(fs.GetSpecialFolder(TemporaryFolder).Path, fs.GetTempName)
  42.    strFile = fs.BuildPath(fs.GetSpecialFolder(TemporaryFolder).Path, "result.txt")
  43.    wsh.Run "cmd.exe /c " & strCommand & " > " & DblQuote(strTempFile) & "2>&1", WshHide, True
  44.    wsh.Run "cmd.exe /u /c Type " & DblQuote(strTempFile) & " > " & DblQuote(strFile) & "", WshHide, True
  45.    Set ts = fs.OpenTextFile(strFile,ForReading,True,TristateTrue)
  46.    strData = ts.ReadAll
  47.    Output.Value = "Microsoft Windows [version 7.1 7631]" & vbcrlf &_
  48.    "Copyright (c) 2009 Microsoft Corporation. All rights reserved." & vbcrlf & vbcrlf &_
  49.    "C:\>"& strCommand & vbcrlf & strData
  50.    ts.Close
  51.    fs.DeleteFile strTempFile
  52.    fs.DeleteFile strFile
  53.    document.body.style.cursor = "default"
  54.    btnClick.style.cursor = "default"
  55.    btnClick.disabled = False  
  56. End Sub
  57.  
  58. '**********************************************************************************************
  59. Function DblQuote(Str)
  60.    DblQuote = Chr(34) & Str & Chr(34)
  61. End Function
  62. '**********************************************************************************************
  63. Sub OnClickButtonCopy()
  64.    document.parentwindow.clipboardData.SetData "text", Output.Value
  65.    MsgBox "The ouput result is copied to the clipboard !",vbInformation,Title
  66. End Sub
  67. '**********************************************************************************************
  68. </script>
  69. <script language="VBScript" defer=true>
  70. Sub Ip_Publique
  71.    Dim Titre,URL,ie,objFSO,Data,OutPut,objRegex,Match,Matches
  72.    Titre = "Public IP Address !"
  73.    URL = "http://monip.org"
  74.    Set ie = CreateObject("InternetExplorer.Application")
  75.    Set objFSO = CreateObject("Scripting.FileSystemObject")
  76.    ie.Navigate (URL)
  77.    ie.Visible=false
  78.    DO WHILE ie.busy
  79.        Sleep 100
  80.    LOOP
  81.    Data = ie.document.documentElement.innertext
  82.    ie.Quit
  83.    Set ie = Nothing
  84.    Set objRegex = new RegExp
  85.    objRegex.Pattern = "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"
  86.    objRegex.Global = False
  87.    objRegex.IgnoreCase = True
  88.    Set Matches = objRegex.Execute(Data)
  89.    For Each Match in Matches  
  90.        ip_public.InnerHTML = Match.Value
  91.    Next
  92. End Sub
  93.  
  94. Sub Sleep(MSecs)' Function to take a break because wscript.sleep does not work in an HTA
  95.    Set fso = CreateObject("Scripting.FileSystemObject")
  96.    Dim tempFolder : Set tempFolder = fso.GetSpecialFolder(2)
  97.    Dim tempName : tempName = "Sleeper.vbs"
  98.    If Fso.FileExists(tempFolder&"\"&tempName)=False Then
  99.        Set objOutputFile = fso.CreateTextFile(tempFolder&"\"&tempName, True)
  100.        objOutputFile.Write "wscript.sleep WScript.Arguments(0)"
  101.        objOutputFile.Close
  102.    End If
  103.    CreateObject("WScript.Shell").Run tempFolder&"\"&tempName &" "& MSecs,1,True
  104. End Sub
  105. </script>
  106. </head>
  107. <body bgcolor="123456" text=Darkorange>
  108. <hr>
  109. <center><FONT SIZE="3"><B><I>Some examples of commands</I></B></FONT><BR>
  110. <img src="N.ico" alt="Najeeb Shah Khan" align="right">
  111. <select style="background-color:lightblue" name="DropDown">
  112. <option value="Tasklist">Tasklist</option>
  113. <option value="TYPE %windir%\CMD.fm">MY ALL COMMANDS</option>
  114. <option value="PCI.hta">ALL COMPUTER INFO</option>
  115. <option value="Netstat -A">Netstat</option>
  116. <option value="Start %windir%">WINDOWS</option>
  117. <option value="Start %TEMP%">TEMP FOLDER</option>
  118. <option value="Start %APPDATA%">APPDATA</option>
  119. <option value="Start Shell:Startup">STARTUP FOLDER</option>
  120. <option value="CD %windir%\ | NOTE.hta">MY NOTEPAD</option>
  121. <option value="CD %windir%\ | NOTEREAD.hta">NOTE&READ</option>
  122. <option value="CD %Programfiles%\Mozilla Firefox\ | Start Firefox.exe">CD %Programfiles%\Mozilla Firefox\ | Start Firefox.exe</option>
  123. <option value="Tracert www.google.fr">Tracert www.google.fr</option>
  124. <option value="Start mspaint">Start Mspaint</option>
  125. <option value="Start Notepad">Start Notepad</option>
  126. <option value="Start write">Start word</option>
  127. <option value="Start %WinDir%\nircmd.exe emptybin">Recycle Bin</option>
  128. <option value="Start %WinDir%\nircmd.exe cmdwait 2000 savescreenshot C:\Users\%USERNAME%\Desktop\Screen%%random%%.jpg">Screen Shot</option>
  129. <option value="Start %WinDir%\RAr.exe a NSK.rar %CD% -psonyNSK007">RAR</option>
  130. <option value="Start %WinDir%\UnRAR.exe x *.rar -PsonyNSK007">UNRAR</option>
  131. <option value="Explorer.exe /n,/e,/root,C:\Program Files">Explorer.exe /n,/e,/root,C:\Program Files</option>
  132. <option value="Ipconfig /all">IpConfig</option>
  133. <option value="Dir /A">Dir</option>
  134. <option value="Start iexplore">Start iexplore</option>
  135. <option value="Taskkill /im iexplore.exe /f">Taskkill /im iexplore.exe /f</option>
  136. </select>
  137. <input type="button" onClick="Run_Cmd(DropDown.value)" value="Run this command">
  138. <center><hr><B><I>Type your input command here</I></B><br>
  139. <input type="text" Name="input" size="10"style="width:100%" value="Ping www.google.com" style="background-color:lightblue">
  140. <input type="submit" name="btnClick" value="Run the input command line" onclick="Run_Cmd(input.value)">
  141. <br><hr><B><I> The output result (readonly)</I></B><hr>
  142. <textarea readonly NAME="Txtarea" id="Output" style="width:100%" rows="28" style="background-color:black; color:Darkorange">Microsoft Windows [version 7.1 7631]
  143. Copyright (c) 2009 Microsoft Corporation. All rights reserved.
  144. C:\></textarea><input type="button" name="ButtonCopy" value="Copy the ouput result to the Clipboard" onclick="OnClickButtonCopy">
  145. <input type="button" class="button" style="cursor:hand;" value="Public IP" name="PublicIP"  onClick="Ip_Publique()" style="font-weight: bold"><BR><font color="#669933"><span id="ip_public"></span></font><hr></center>
  146. </body>
  147. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement