|
241
|
Programación / Programación Visual Basic / Re: Api de winsock
|
en: 27 Marzo 2006, 02:11 am
|
pero eso q tiene q ver si es de conexion inversa :S ?? corrigeme si me equivoco Te corrijo. Ahora la mayoria de los firewalls (menos el del WinXP SP2, segun tengo entendido) controlan la entrada y SALIDA de datos. Si tenes el firewall del SP2 o algun otro desactivalo, porque acordate que el programa esta tratando de conectarse a tu pc. Lo mismo con la victima. Saludos.-
|
|
|
245
|
Programación / Programación Visual Basic / Re: Interprete de Dos
|
en: 23 Marzo 2006, 23:53 pm
|
En un módulo: Public Declare Function CreatePipe Lib "kernel32" ( _ phReadPipe As Long, _ phWritePipe As Long, _ lpPipeAttributes As Any, _ ByVal nSize As Long) As Long 'Leer Tunel Public Declare Function ReadFile Lib "kernel32" ( _ ByVal hFile As Long, _ ByVal lpBuffer As String, _ ByVal nNumberOfBytesToRead As Long, _ lpNumberOfBytesRead As Long, _ ByVal lpOverlapped As Any) As Long 'Esto lo usa la funcion CreateProcessA Public Type SECURITY_ATTRIBUTES nLength As Long lpSecurityDescriptor As Long bInheritHandle As Long End Type 'Esto lo usa la funcion CreateProcessA Public 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 Long hStdInput As Long hStdOutput As Long hStdError As Long End Type 'Esto lo usa la funcion CreateProcessA Public Type PROCESS_INFORMATION hProcess As Long hThread As Long dwProcessId As Long dwThreadID As Long End Type 'Esta funcion lanza el proceso y 'devuelve sus datos a traves de PROCESS_INFORMATION Public Declare Function CreateProcessA Lib "kernel32" ( _ ByVal lpApplicationName As Long, _ ByVal lpCommandLine As String, _ lpProcessAttributes As SECURITY_ATTRIBUTES, _ lpThreadAttributes As SECURITY_ATTRIBUTES, _ ByVal bInheritHandles As Long, _ ByVal dwCreationFlags As Long, _ ByVal lpEnvironment As Long, _ ByVal lpCurrentDirectory As Long, _ lpStartupInfo As STARTUPINFO, _ lpProcessInformation As PROCESS_INFORMATION) As Long 'Cierra el tunel Public Declare Function CloseHandle Lib "kernel32" ( _ ByVal hHandle As Long) As Long 'Constantes necesarias para lo de antes Public Const NORMAL_PRIORITY_CLASS = &H20& Public Const STARTF_USESTDHANDLES = &H100& Public Const STARTF_USESHOWWINDOW = &H1
Public Function CMD(ByVal Comando As String) As String On Error GoTo ACAGAR Dim proc As PROCESS_INFORMATION 'Informacion de CreateProcessA Dim Ret As Long 'Esto se usa para obtener el retorno de las 'funciones API Dim start As STARTUPINFO 'Informacion de inicio para CreateProcessA Dim sa As SECURITY_ATTRIBUTES 'Atributos de seguridad para 'CreateProcessA Dim hReadPipe As Long 'Lectura de Tunel Dim hWritePipe As Long 'Escritura de Tunel Dim lngBytesread As Long 'Cantidad de Bytes leidos Dim strBuff As String * 256 'Buffer de lectura de tunel 'Creamos el tunel... sa.nLength = Len(sa) sa.bInheritHandle = 1& sa.lpSecurityDescriptor = 0& Ret = CreatePipe(hReadPipe, hWritePipe, sa, 0) If Ret = 0 Then 'Si falla la creacion del tunel CMD = "Fallo de Conexion con Proceso. Error: " & Err.LastDllError Exit Function End If 'Lanzamos el interprete de comandos... start.cb = Len(start) start.dwFlags = STARTF_USESTDHANDLES Or STARTF_USESHOWWINDOW start.hStdOutput = hWritePipe start.hStdError = hWritePipe 'Buscar la ruta del CMD.exe y añadir /c y el comando mCommand = Environ("COMSPEC") + " /c " + Comando 'Creamos el proceso usando la String mCommand de antes... 'y obtenemos RET para saber si se ha ejecutado Ret& = CreateProcessA(0&, mCommand, sa, sa, 1&, _ NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc) If Ret <> 1 Then 'si no se encuentra el comando... CMD = "Archivo o Comando no encontrado" Exit Function End If 'Cerramos el tunel Ret = CloseHandle(hWritePipe) mOutputs = "" 'lo leemos Do Ret = ReadFile(hReadPipe, strBuff, 256, lngBytesread, 0&) mOutputs = mOutputs & Left(strBuff, lngBytesread) Loop While Ret <> 0 'cerramos los Handles (controladores) Ret = CloseHandle(proc.hProcess) Ret = CloseHandle(proc.hThread) Ret = CloseHandle(hReadPipe) 'y hacemos que la funcion devuelva el resultado del comando a traves ' de la string mOutputs CMD = mOutputs Exit Function ACAGAR: CMD = "Error:" + Err.Description End Function
Luego para usarlo: Respuesta = CMD("tasklist") 'ahi puede ir una variable...
Saludos.-
|
|
|
248
|
Programación / Programación Visual Basic / Re: comparar Imagenes
|
en: 21 Marzo 2006, 20:05 pm
|
Eso es con archivos guardados en la pc, si queres trabajar con imagenes en tiempo de ejecucion podes usar la api GetPixelPrivate Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Sub Form_Load() Picture1.ScaleMode = vbPixels MsgBox GetPixel(Picture1.hdc, 10, 10) End Sub
Eso te daria el color del pixel que hay en el Picutre1 en las coordenadas 10, 10. Te podes fijar en dos imagenes diferentes las mismas coordenadas, asi si son diferentes, el color va a ser distinto. Saludos.-
|
|
|
249
|
Programación / Programación Visual Basic / Re: Titulo completo de ventana
|
en: 21 Marzo 2006, 19:53 pm
|
Copio el modulo sacado del proyecto de LeandroA ( http://foro.elhacker.net/index.php/topic,113051.msg521902.html#msg521902) Option Explicit Declare Function GetWindowText Lib "User32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Declare Function GetWindow Lib "User32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal wIndx As Long) As Long Declare Function GetWindowTextLength Lib "User32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Public Const MAX_PATH As Integer = 260 Const GWL_STYLE = (-16) Const Win_VISIBLE = &H10000000 Const Win_BORDER = &H800000 Const SC_CLOSE = &HF060& Const WM_SYSCOMMAND = &H112 Dim ListaProcesos As Object Dim ObjetoWMI As Object Dim ProcesoACerrar As Object
Public Sub EnumTopWindows() Dim IsTask As Long, hwCurr As Long, intLen As Long, strTitle As String IsTask = Win_VISIBLE Or Win_BORDER hwCurr = GetWindow(Form1.hWnd, 0) Do While hwCurr If hwCurr <> Form1.hWnd And (GetWindowLong(hwCurr, GWL_STYLE) And IsTask) = IsTask Then intLen = GetWindowTextLength(hwCurr) + 1 strTitle = Space$(intLen) intLen = GetWindowText(hwCurr, strTitle, intLen) If intLen > 0 Then Form1.List1.AddItem strTitle End If End If hwCurr = GetWindow(hwCurr, 2) Loop End Sub
Public Sub CloseApp(ByVal Titulo As String, Optional ClassName As String) Call SendMessage(FindWindow(ClassName, Titulo), WM_SYSCOMMAND, SC_CLOSE, ByVal 0&) End Sub
Public Sub Procesos() Set ObjetoWMI = GetObject("winmgmts:") If IsNull(ObjetoWMI) = False Then Set ListaProcesos = ObjetoWMI.InstancesOf("win32_process") For Each ProcesoACerrar In ListaProcesos Form1.List2.AddItem LCase$(ProcesoACerrar.Name) Next End If Set ListaProcesos = Nothing Set ObjetoWMI = Nothing End Sub
Despues para usarlo es facil: Tenes que tener 2 lstbox (List1 y List2) y despues desde cualquier evento llamas a Saludos.-
|
|
|
250
|
Programación / Programación Visual Basic / Re: Titulo completo de ventana
|
en: 21 Marzo 2006, 19:40 pm
|
Weno, como puedo saber, a partir de un trozo del titulo, kual es el titulo kompleto????
Por ejemplo, Supongamos que abro el Bloc de notas, y el titulo de la ventana es esto:
Sin titulo - Bloc de notas
Supongamos que yo quiero, a partir de Bloc de notas, que me diga todo el titulo de la ventana (es decir, Sin titulo - Bloc de notas).
Komo puedo hacer esto????
Weno, Gracias
Salu2
Podes listar todas las ventanas y despues hacer un bucle buscando una parte de la ventana con IF, x ejemplo: If Right(Ventana, 5) = "notas" then msgbox Ventana End if
|
|
|
|
|
|
|