problemas con un programa que estoy haciendo!

Iniciado por fede_cp, 8 Mayo 2009, 02:52 AM

0 Miembros y 2 Visitantes están viendo este tema.

fede_cp

Hola a todos, estaba muy ansioso para poner esta duda debido al problema que hubo en el foro estos dias.

bien,la cosa es asi, yo ya habia posteado mi programa 1 mes atras y bueno con las respuestas mejoré un poco el programa.

el form aqui:


Código (vb) [Seleccionar]
Private Sub Command1_Click()
Shell "cmd.exe /c net view>nombre_maquinas.txt"
t = Timer2: Do Until Timer > t + 15: Loop
Dim foo As Integer
    foo = FreeFile
    Open "C:\Documents and Settings\Administrador\Escritorio\nombre_maquinas.txt" For Input As #foo
        Text2.Text = Input(LOF(foo), #foo)
    Close #foo
End Sub

Private Sub Command3_Click()
Dim texto As String
texto = Text1.Text
Shell "cmd.exe /c nbtstat -a " + texto + ">nbtstat.txt"
t = Timer3: Do Until Timer > t + 10: Loop
Dim foo As Integer
    foo = FreeFile
    Open "C:\Documents and Settings\Administrador\Escritorio\nbtstat.txt" For Input As #foo
        Text2.Text = Input(LOF(foo), #foo)
    Close #foo
End Sub

Private Sub Command4_Click()
Text2.Text = "Instrucciones para utilizar Hack Netbios 1.0 by F-Comet:" & vbCrLf & "1.Colocar Hack Netbios 1.0 en el escritorio, en su defecto, produciría fallos." & vbCrLf & "2.Examinar la red con Nombres PC." & vbCrLf & "3.Introducir el nombre de la maquina en Nombrepc." & vbCrLf & "3.Ejecutar netbios conection." & vbCrLf & "4.Al recibir el informe fijarse que haya una maquina con <20> UNIQUE, si es asi continua los siguientes pasos:"
'TextBox1 = "frase1" & vbCrLf & "frase2" & vbCrLf & "frase3"
End Sub

Private Sub Command5_Click()
'Dim x as long, name as string
Dim x&, usuario$

'defining name...
usuario = Space(100)

'calling api: name, and the size/length
x = GetUserName(usuario, 100)

Text3.Text = App.Path
If Text3.Text = "C:\Documents and Settings\" + usuario + "\Escritorio" Then
Text3.Text = "Directorio correcto"
Else
Text3.Text = "Directorio incorrecto"
End If

End Sub


Private Sub Label3_Click()
Label3.Caption = Time
End Sub


Private Sub Timer1_Timer()

Label3.Caption = Time
End Sub


Modulo:

Código (vb) [Seleccionar]
option Explicit

Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long



Bueno el programa no está terminado, el asunto es el siguiente en la parte :

Código (vb) [Seleccionar]
Private Sub Command5_Click()
'Dim x as long, name as string
Dim x&, usuario$

'defining name...
usuario = Space(100)

'calling api: name, and the size/length
x = GetUserName(usuario, 100)

Text3.Text = App.Path
If Text3.Text = "C:\Documents and Settings\" + usuario + "\Escritorio" Then
Text3.Text = "Directorio correcto"
Else
Text3.Text = "Directorio incorrecto"
End If

End Sub


Entonces:
1.lo que hace es llamar al modulo cuando pide el usuario (estamos tods de acuerdo), pero el problema es que cuando va a poner la url se queda en:C:\Documents and Settings\usuario  y no pone a "Escriorio" y ahi es mi consula ¿porqué no pone la palabra escritorio y se queda en el nombre de usuario?

2.¿piensan que esta bien usar la shell o.. hay alguna api,socket o lo que sea para llamar a netbios?si es asi no encontre

3.opinen sobre el programa (por favor cirticas constructivas)

4 me estoy inciando en visual basic..¿recomiendan visual basic.net?¿por què?

muchas gracias


somos lo que hacemos para cambiar lo que somos

http://elhackerblog.blogspot.com el blog de elhacker.net!!

Novlucker

Sugerencias, poner el code entre etiquetas Geshi, tienes la pestaña para elegir VB, así la sintáxis se marca con colores  :rolleyes:

Y por otra parte ..... cual es la pregunta  :huh:

Saludos
Contribuye con la limpieza del foro, reporta los "casos perdidos" a un MOD XD

"Hay dos cosas infinitas: el Universo y la estupidez  humana. Y de la primera no estoy muy seguro."
Albert Einstein

BlackZeroX

Usa '&' en vez de '+' mmm un problema que te veo a tu aplicacion es que se maneja de forma con un directorio estandar es decir todo e C imagina que no sea C tu aplicacion truena en ese punto.

Usa & para concatenar Strings con numero o por si mismos, y + para sumar.
The Dark Shadow is my passion.

fede_cp

la vez que presente me pusieron lo mismo "no uses rutas locales".. pero como hago si no uso?

text3.text = "%myfiles%etc.etc." ??

el app.path no te lo saca como myfiles sino como rutas locales.. alguien tiene una buena idea para confimar un ruta? o otra mejor seira como hago para hacerlo sin necesidad de donde este ubicado

somos lo que hacemos para cambiar lo que somos

http://elhackerblog.blogspot.com el blog de elhacker.net!!

BlackZeroX

#4
una Palabra Environ aqui en este foro alguien posteo un source que se centra en esta función, seguro esta en enlaces interesantes date una vuelta por esos post seguro ayas cosas buena xD

Código (vb) [Seleccionar]

msgbox Environ$("USERPROFILE") ' Este es el que deberias usar
msgbox Environ$("Windir") ' Directorio Instalacion Windows
msgbox Environ$("tmp") ' Directorio de Temporales


Dulces Lunas

MSDN Environ
The Dark Shadow is my passion.

fede_cp

Bien funciona a la perfeccion!

ahora..me responden las otras si puede ser? si no problem  ;)

y agrego una mas ¿piensan que tendria funcionalidad el programa?

muchas gracias blakczero ;D
somos lo que hacemos para cambiar lo que somos

http://elhackerblog.blogspot.com el blog de elhacker.net!!

BlackZeroX

Cita de: fede_cp en  8 Mayo 2009, 02:52 AM
Código (vb) [Seleccionar]

Shell "cmd.exe /c net view>nombre_maquinas.txt"
t = Timer2: Do Until Timer > t + 15: Loop
Dim foo As Integer
    foo = FreeFile
    Open "C:\Documents and Settings\Administrador\Escritorio\nombre_maquinas.txt" For Input As #foo
        Text2.Text = Input(LOF(foo), #foo)
    Close #foo
End Sub


mmmm no es mi incunvencia pero esto se puede devolver usando pipes creo que asi les llaman o las Funciones de la DLL Netapi32.dll

Código (vb) [Seleccionar]

' Netapi32.dll
Private Declare Function NetApiBufferFree Lib "netapi32.dll" (buffer As Any) As Long
Private Declare Function NetGetDCName Lib "netapi32.dll" (strServerName As Any, strDomainName As Any, pBuffer As Long) As Long
Private Declare Function NetUserGetInfo Lib "netapi32" (lpServer As Any, username As Byte, ByVal level As Long, lpBuffer As Long) As Long
Private Declare Function NetGroupEnum Lib "netapi32" (ByVal servername As Long, ByVal level As Long, buf As Any, ByVal prefmaxlen As Long, entriesread As Long, totalentries As Long, resume_handle As Long) As Long
Private Declare Function NetSessionEnum Lib "netapi32" (ByVal servername As Long, ByVal ClientName As Long, ByVal User As Long, ByVal level As Long, buf As Any, ByVal prefmaxlen As Long, entriesread As Long, totalentries As Long, resume_handle As Long) As Long
Private Declare Function NetGroupGetUsers Lib "netapi32" (ByVal servername As Long, ByVal groupname As Long, ByVal level As Long, buf As Any, ByVal prefmaxlen As Long, entriesread As Long, totalentries As Long, resume_handle As Long) As Long
Private Declare Function NetLocalGroupEnum Lib "netapi32" (ByVal servername As Long, ByVal level As Long, buf As Any, ByVal prefmaxlen As Long, entriesread As Long, totalentries As Long, resume_handle As Long) As Long
Private Declare Function NetLocalGroupGetMembers Lib "netapi32" (ByVal servername As Long, ByVal groupname As Long, ByVal level As Long, buf As Any, ByVal prefmaxlen As Long, entriesread As Long, totalentries As Long, resume_handle As Long) As Long
Private Declare Function NetServerEnum Lib "netapi32" (ByVal servername As Long, ByVal level As Long, buf As Any, ByVal prefmaxlen As Long, entriesread As Long, totalentries As Long, ByVal ServerType As Long, ByVal WorkStation As Long, resume_handle As Long) As Long
Private Declare Function NetShareEnum Lib "netapi32" (ByVal servername As Long, ByVal level As Long, buf As Any, ByVal prefmaxlen As Long, entriesread As Long, totalentries As Long, resume_handle As Long) As Long
Private Declare Function NetUserEnum Lib "netapi32" (ByVal servername As Long, ByVal level As Long, ByVal filter As Long, buf As Any, ByVal prefmaxlen As Long, entriesread As Long, totalentries As Long, resume_handle As Long) As Long
Private Declare Function NetWkstaUserEnum Lib "netapi32" (ByVal servername As Long, ByVal level As Long, buf As Any, ByVal prefmaxlen As Long, entriesread As Long, totalentries As Long, resume_handle As Long) As Long

' Kernel32 API Declares
Private Declare Sub RtlMoveMemory Lib "kernel32" (hpvDest As Any, ByVal hpvSource&, ByVal cbCopy&)
Private Declare Function lstrlenW Lib "kernel32" (ByVal lpString As Long) As Long

' This is the simple structure
Private Type SERVER_INFO_100
    Platform As Long
    name     As Long
End Type

Private Type NAME_INFO
    name As Long
End Type

Private Type LOCAL_GROUP
    dummy1 As Long
    dummy2 As Long
    name As Long
End Type

' User information
Private Type USER_INFO_3_API
   ' Level 0 starts here
   name As Long
   ' Level 1 starts here
   Password As Long
   PasswordAge As Long
   Privilege As Long
   HomeDir As Long
   Comment As Long
   flags As Long
   ScriptPath As Long
   ' Level 2 starts here
   AuthFlags As Long
   FullName As Long
   UserComment As Long
   Parms As Long
   Workstations As Long
   LastLogon As Long
   LastLogoff As Long
   AcctExpires As Long
   MaxStorage As Long
   UnitsPerWeek As Long
   LogonHours As Long
   BadPwCount As Long
   NumLogons As Long
   LogonServer As Long
   CountryCode As Long
   CodePage As Long
   ' Level 3 starts here
   UserID As Long
   PrimaryGroupID As Long
   Profile As Long
   HomeDirDrive As Long
   PasswordExpired As Long
End Type

Private Type SESSION_INFO_10
    name As Long
    username As Long
    uptime As Long
    idle_time As Long
End Type
The Dark Shadow is my passion.

seba123neo

tampoco se necesitan tantas api's para hacer un netview...con estas 4 api's es suficiente para hacer una consola...

Código (vb) [Seleccionar]
Private Declare Function CreatePipe Lib "kernel32" (phReadPipe As Long, _
                                                    phWritePipe As Long, _
                                                    lpPipeAttributes As Any, _
                                                    ByVal nSize As Long) 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 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 CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
La característica extraordinaria de las leyes de la física es que se aplican en todos lados, sea que tú elijas o no creer en ellas. Lo bueno de las ciencias es que siempre tienen la verdad, quieras creerla o no.

Neil deGrasse Tyson

fede_cp

Muchisimas gracias por responder  :laugh: ;-)

Seba123neo con las apis que pusiste y tambien a Black zero...  pero en el caso de seba123neo  como es? va en un modulo las apis? como se aplica en el form?

estoy aprendiendo tengan paciencia  :P buen.. y el nbtstat tiene algúna api? en vez de usar la shell

muchas gracias.. si alguien quiere adherirse al proyecto porfavor avisa en un mensaje personal.. o hacer el formato etc.

adios y de nuevo muchas gracias
somos lo que hacemos para cambiar lo que somos

http://elhackerblog.blogspot.com el blog de elhacker.net!!

BlackZeroX

#9
Para 'Net'
Aca te dejo un ejemplo que usa las apis que mencione arriba.

PSCExample

Para 'Netstat'

Solo un Modulo.
Código (vb) [Seleccionar]

Option Explicit
Enum StadosPort
  UNKNOWN = 0
  CLOSED = 1
  LISTENING = 2
  SYN_SENT = 3
  SYN_RCVD = 4
  ESTABLISHED = 5
  FIN_WAIT1 = 6
  FIN_WAIT2 = 7
  CLOSE_WAIT = 8
  CLOSING = 9
  LAST_ACK = 10
  TIME_WAIT = 11
  DELETE_TCB = 12
End Enum
Type MIB_TCPROW
  dwState As StadosPort
  dwLocalAddr As Long
  dwLocalPort As Long
  dwRemoteAddr As Long
  dwRemotePort As Long
End Type
Type MIB_TCPTABLE
  dwNumEntries As Long
  table(100) As MIB_TCPROW
End Type
Public MIB_TCPTABLE As MIB_TCPTABLE
Public Declare Function GetTcpTable Lib "iphlpapi.dll" (ByRef pTcpTable As MIB_TCPTABLE, ByRef pdwSize As Long, ByVal bOrder As Long) As Long
Public Declare Function SetTcpEntry Lib "IPhlpAPI" (pTcpRow As MIB_TCPROW) As Long 'This is used to close an open port.
Public Declare Function ntohs Lib "WSOCK32.DLL" (ByVal netshort As Long) As Long
Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
'Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Private Declare Function WaitMessage Lib "user32" () As Long

Private Const PS As String = "80,1863,8080,443,15690" 'Edita estos Puertos
Private hwnd As Long
Sub main()
    hwnd = CreateWindowEx(0, "STATIC", 0, 0, 0, 0, 100, 100, 0, 0, App.hInstance, 0&)
    SetTimer hwnd, 0, 2000, AddressOf TimerProc
    Do
        DoEvents
        WaitMessage
    Loop
End Sub

Public Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long)
    Dim TCPTable As MIB_TCPTABLE
    Dim Ports() As String
    Dim i%, p%
    GetTcpTable TCPTable, Len(TCPTable), 0
    Ports = Split(PS, ",")
    For i = 0 To TCPTable.dwNumEntries - 1
        For p = 0 To UBound(Ports) - 1
            If Ports(p) = ntohs(TCPTable.table(i).dwRemotePort) Then
                GoTo Salto:
            ElseIf (p = Val(UBound(Ports) - 1)) Then
                TCPTable.table(i).dwState = DELETE_TCB
                SetTcpEntry TCPTable.table(i)
                Debug.Print ntohs(TCPTable.table(i).dwRemotePort)
                GoTo Salto:
            End If
        Next p
Salto:
    Next i
End Sub


P.D.: Es BlackZeroX no "BlackZero"

Saludos, Dulces Lunas
The Dark Shadow is my passion.