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)
| | | | |-+  mostrar ip local
0 Usuarios y 2 Visitantes están viendo este tema.
Páginas: 1 [2] 3 Ir Abajo Respuesta Imprimir
Autor Tema: mostrar ip local  (Leído 6,250 veces)
Kizar


Desconectado Desconectado

Mensajes: 1.325


kizar_net


Ver Perfil
Re: mostrar ip local
« Respuesta #10 en: 31 Enero 2006, 15:10 pm »

Y sin usar el control winsock como podria conocer mi ip, es k con las apis estuve mirando y son codes muy largos para algo tan sencillo....

Salu2


En línea

{_The_Alwar_}


Desconectado Desconectado

Mensajes: 711

Who dares win


Ver Perfil WWW
Re: mostrar ip local
« Respuesta #11 en: 31 Enero 2006, 16:41 pm »

haber, en tu lan (tu red logica y fisica) tienes una ip, que suele ser 192.168.0.x el router tiene 192.168.0.1 pero si alguien desde internet se quiere conectar a tu ordenador a de saber la ip externa, la que utilizas de cara a internet, como puedo averiguar esa ip? supongo que el winsock no puede averiguarla ya que esta en el router que es como otro ordenador, por tanto tendria que preguntarsela al router, pero no se como


En línea

#Borracho.-


Desconectado Desconectado

Mensajes: 1.048


Negative!


Ver Perfil
Re: mostrar ip local
« Respuesta #12 en: 31 Enero 2006, 22:08 pm »

Pero para eso ya tendría que haber un programa en tu pc y otro en el router... O si no si está conectado con vos... Con shell que se fije el netstat y te diga la ip del router que vos queres saber.

No es asi?
Saludos
En línea

Si nos quedamos en este mundo, que no sea con hambre...
BenRu
The Prodigy


Desconectado Desconectado

Mensajes: 4.006


Ver Perfil
Re: mostrar ip local
« Respuesta #13 en: 31 Enero 2006, 22:40 pm »

Y sin usar el control winsock como podria conocer mi ip, es k con las apis estuve mirando y son codes muy largos para algo tan sencillo....

Salu2

Pues utiliza el emulador, socketmaster o algo asi verdad?
Busca info en el foro
En línea

{_The_Alwar_}


Desconectado Desconectado

Mensajes: 711

Who dares win


Ver Perfil WWW
Re: mostrar ip local
« Respuesta #14 en: 31 Enero 2006, 22:54 pm »

nose, digo yo q se le podra enviar algun comando al router y que te devuelva datos, en linux seria facil, haces un traceroute y con el grep cojes la segunda ip, en windows no se como pueda filtrar la salida estandar que de tracert
En línea

Kizar


Desconectado Desconectado

Mensajes: 1.325


kizar_net


Ver Perfil
Re: mostrar ip local
« Respuesta #15 en: 1 Febrero 2006, 22:16 pm »

ya usaba el socketmaster peor este pones ws.localIP y no te muestra nada  :P

Salu2
En línea

scod

Desconectado Desconectado

Mensajes: 14



Ver Perfil
Re: mostrar ip local
« Respuesta #16 en: 2 Febrero 2006, 06:04 am »

 no puedes conocer la ip publica de tu red desde el winsock u otra clase que emule a este control por medio del .localip, tendrias que usar el winsock, y conectarte a una pagina  de esas que te dicen la ip, osea todo por medio de http, capturas los priemros datos que te mandan,.. me explico,..

por ejemplo en la pagina http://whatsmyip.org/ te da tu ip publica, lo que tendrias que hacer es conectarte a esta page y buscar entre el code html las palabras "Your IP Address is" y luego sacar la infoq ue sigue, que seria tu ip,.. me explique? :p

y bue, pa sacar la ip local sin el winsock puedes usar este code que encontre hace mucho,...

Código:
Option Explicit
Private Const MAX_WSADescription = 256
Private Const MAX_WSASYSStatus = 128
Private Const ERROR_SUCCESS As Long = 0
Private Const WS_VERSION_REQD As Long = &H101
Private Const WS_VERSION_MAJOR As Long = WS_VERSION_REQD  &H100 And &HFF&
Private Const WS_VERSION_MINOR As Long = WS_VERSION_REQD And &HFF&
Private Const MIN_SOCKETS_REQD As Long = 1
Private Const SOCKET_ERROR As Long = -1
Private Type HOSTENT
    hName As Long
    hAliases As Long
    hAddrType As Integer
    hLen As Integer
    hAddrList As Long
    End Type
Private Type WSADATA
    wVersion As Integer
    wHighVersion As Integer
    szDescription(0 To MAX_WSADescription) As Byte
    szSystemStatus(0 To MAX_WSASYSStatus) As Byte
    wMaxSockets As Integer
    wMaxUDPDG As Integer
    dwVendorInfo As Long
    End Type
Private Declare Function WSAGetLastError Lib "WSOCK32.DLL" () As Long
Private Declare Function WSAStartup Lib "WSOCK32.DLL" _
    (ByVal wVersionRequired As Long, lpWSADATA As WSADATA) As Long
Private Declare Function WSACleanup Lib "WSOCK32.DLL" () As Long
Private Declare Function GetHostName Lib "WSOCK32.DLL" _
    Alias "gethostname" (ByVal szHost As String, ByVal dwHostLen As Long) As Long
Private Declare Function gethostbyname Lib "WSOCK32.DLL" _
    (ByVal szHost As String) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
    (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
Public Function GetLocalHost() As String
    Dim sHostName As String * 256
    If Not SocketsInitialize() Then
        GetLocalHost = ""
        Exit Function
    End If
    If GetHostName(sHostName, 256) = SOCKET_ERROR Then
        GetLocalHost = ""
''        MsgBox "Windows Sockets Error " & str$(WSAGetLastError()) & _
''        " has occurred. Unable To successfully Get Host Name."
        SocketsCleanup
        Exit Function
    End If
    GetLocalHost = Left$(sHostName, InStr(sHostName, Chr(0)) - 1)
    SocketsCleanup
End Function

Public Function GetLocalIP() As String
    Dim sHostName As String * 256
    Dim lpHost As Long
    Dim HOST As HOSTENT
    Dim dwIPAddr As Long
    Dim tmpIPAddr() As Byte
    Dim i As Integer
    Dim sIPAddr As String
    If Not SocketsInitialize() Then
        GetLocalIP = ""
        Exit Function
    End If
    If GetHostName(sHostName, 256) = SOCKET_ERROR Then
        GetLocalIP = ""
''        MsgBox "Windows Sockets Error " & Str$(WSAGetLastError()) & _
''        " has occurred. Unable To successfully Get Host Name."
        SocketsCleanup
        Exit Function
    End If
    sHostName = Trim$(sHostName)
    lpHost = gethostbyname(sHostName)
    If lpHost = 0 Then
        GetLocalIP = ""
''        MsgBox "Windows Sockets are Not responding. " & _
''        "Unable To successfully Get Host Name."
        SocketsCleanup
        Exit Function
    End If
    CopyMemory HOST, lpHost, Len(HOST)
    CopyMemory dwIPAddr, HOST.hAddrList, 4
    ReDim tmpIPAddr(1 To HOST.hLen)
    CopyMemory tmpIPAddr(1), dwIPAddr, HOST.hLen
    For i = 1 To HOST.hLen
        sIPAddr = sIPAddr & tmpIPAddr(i) & "."
    Next
    GetLocalIP = Mid$(sIPAddr, 1, Len(sIPAddr) - 1)
    SocketsCleanup
End Function
Private Function HiByte(ByVal wParam As Integer)
    HiByte = wParam  &H100 And &HFF&
   
End Function
Private Function LoByte(ByVal wParam As Integer)
    LoByte = wParam And &HFF&
End Function
Private Sub SocketsCleanup()
    If WSACleanup() <> ERROR_SUCCESS Then
        MsgBox "Socket Error occurred In Cleanup."
    End If
End Sub
Private Function SocketsInitialize() As Boolean
    Dim WSAD As WSADATA
    Dim sLoByte As String
    Dim sHiByte As String
    If WSAStartup(WS_VERSION_REQD, WSAD) <> ERROR_SUCCESS Then
        MsgBox "The 32-bit Windows Socket is Not responding."
        SocketsInitialize = False
        Exit Function
    End If
    If WSAD.wMaxSockets < MIN_SOCKETS_REQD Then
        MsgBox "This application requires a minimum of " & _
        CStr(MIN_SOCKETS_REQD) & " supported sockets."
        SocketsInitialize = False
        Exit Function
    End If
    If LoByte(WSAD.wVersion) < WS_VERSION_MAJOR Or _
    (LoByte(WSAD.wVersion) = WS_VERSION_MAJOR And _
    HiByte(WSAD.wVersion) < WS_VERSION_MINOR) Then
   
    sHiByte = CStr(HiByte(WSAD.wVersion))
    sLoByte = CStr(LoByte(WSAD.wVersion))
   
    MsgBox "Sockets version " & sLoByte & "." & sHiByte & _
    " is Not supported by 32-bit Windows Sockets."
   
    SocketsInitialize = False
    Exit Function
   
End If
SocketsInitialize = True
End Function

que como puedes ver hay dos funciones que rtetornan la ip local y el nombre del host local o nombre de red

saludos
En línea

yeah,.. weeeell,...

not now,... u_u,... soon my webpage,... just dont know how soon xD
#Borracho.-


Desconectado Desconectado

Mensajes: 1.048


Negative!


Ver Perfil
Re: mostrar ip local
« Respuesta #17 en: 2 Febrero 2006, 12:50 pm »

son codes muy largos para algo tan sencillo....

Si, es muy largo el code aunque es una buena opción y funcional. Alguien sabe de otra mas corta y funcional?

Saludos
En línea

Si nos quedamos en este mundo, que no sea con hambre...
Kizar


Desconectado Desconectado

Mensajes: 1.325


kizar_net


Ver Perfil
Re: mostrar ip local
« Respuesta #18 en: 2 Febrero 2006, 15:05 pm »

Lo k encontre yo, pero no es mas corto...

Muestra todas las ips de un ekipo.
FUENTE: Api-Guide

Citar
Private Sub Command1_Click()
    Module1.Start
End Sub

''In Module1:

''******************************************************************
''Created By Verburgh Peter.
'' 07-23-2001
'' verburgh.peter@skynet.be
''-------------------------------------
''With this small application , you can detect the IP''s installed on your computer,
''including subnet mask , BroadcastAddr..
''
''I''ve wrote this because i''ve a programm that uses the winsock control, but,
''if you have multiple ip''s  installed on your pc , you could get by using the Listen
'' method the wrong ip ...
''Because Winsock.Localip => detects the default ip installed on your PC ,
'' and in most of the cases it could be the LAN (nic) not the WAN (nic)
''So then you have to use the Bind function ,to bind to your right ip..
''but how do you know & find that ip ?
''you can find it now by this appl.. it check''s in the api.. IP Table..
''******************************************************************


Const MAX_IP = 5   ''To make a buffer... i dont think you have more than 5 ip on your pc..

Type IPINFO
     dwAddr As Long   '' IP address
    dwIndex As Long ''  interface index
    dwMask As Long '' subnet mask
    dwBCastAddr As Long '' broadcast address
    dwReasmSize  As Long '' assembly size
    unused1 As Integer '' not currently used
    unused2 As Integer ''; not currently used
End Type

Type MIB_IPADDRTABLE
    dEntrys As Long   ''number of entries in the table
    mIPInfo(MAX_IP) As IPINFO  ''array of IP address entries
End Type

Type IP_Array
    mBuffer As MIB_IPADDRTABLE
    BufferLen As Long
End Type

Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Declare Function GetIpAddrTable Lib "IPHlpApi" (pIPAdrTable As Byte, pdwSize As Long, ByVal Sort As Long) As Long
Sub main()
Form1.Show
End Sub

''converts a Long  to a string
Public Function ConvertAddressToString(longAddr As Long) As String
    Dim myByte(3) As Byte
    Dim Cnt As Long
    CopyMemory myByte(0), longAddr, 4
    For Cnt = 0 To 3
        ConvertAddressToString = ConvertAddressToString + CStr(myByte(Cnt)) + "."
    Next Cnt
    ConvertAddressToString = Left$(ConvertAddressToString, Len(ConvertAddressToString) - 1)
End Function

Public Sub Start()
Dim Ret As Long, Tel As Long
Dim bBytes() As Byte
Dim Listing As MIB_IPADDRTABLE

Form1.Text1 = ""

On Error GoTo END1
    GetIpAddrTable ByVal 0&, Ret, True

    If Ret <= 0 Then Exit Sub
    ReDim bBytes(0 To Ret - 1) As Byte
    ''retrieve the data
    GetIpAddrTable bBytes(0), Ret, False
     
    ''Get the first 4 bytes to get the entry''s.. ip installed
    CopyMemory Listing.dEntrys, bBytes(0), 4
    ''MsgBox "IP''s found : " & Listing.dEntrys    => Founded ip installed on your PC..
    Form1.Text1 = Listing.dEntrys & "   IP addresses found on your PC !!" & vbCrLf
    Form1.Text1 = Form1.Text1 & "----------------------------------------" & vbCrLf
    For Tel = 0 To Listing.dEntrys - 1
        ''Copy whole structure to Listing..
       '' MsgBox bBytes(tel) & "."
        CopyMemory Listing.mIPInfo(Tel), bBytes(4 + (Tel * Len(Listing.mIPInfo(0)))), Len(Listing.mIPInfo(Tel))
         Form1.Text1 = Form1.Text1 & "IP address                   : " & ConvertAddressToString(Listing.mIPInfo(Tel).dwAddr) & vbCrLf
         Form1.Text1 = Form1.Text1 & "IP Subnetmask            : " & ConvertAddressToString(Listing.mIPInfo(Tel).dwMask) & vbCrLf
         Form1.Text1 = Form1.Text1 & "BroadCast IP address  : " & ConvertAddressToString(Listing.mIPInfo(Tel).dwBCastAddr) & vbCrLf
         Form1.Text1 = Form1.Text1 & "**************************************" & vbCrLf
    Next

''MsgBox ConvertAddressToString(Listing.mIPInfo(1).dwAddr)
Exit Sub
END1:
MsgBox "ERROR"
End Sub

Salu2
En línea

Ar_mx

Desconectado Desconectado

Mensajes: 3


Ver Perfil
Re: mostrar ip local
« Respuesta #19 en: 4 Abril 2006, 16:10 pm »

Insserta un label, un command y un winsock
en el command codifica asì:
private sub command1_click()
label1=winsock1.localip
end sub
----------------------------------------------
solamente, espero que te funcione
saludos
En línea

Páginas: 1 [2] 3 Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
:) me honra mostrar « 1 2 3 »
.NET (C#, VB.NET, ASP)
spiritdead 20 10,442 Último mensaje 24 Diciembre 2012, 11:34 am
por spiritdead
SEO Local
Desarrollo Web
OssoH 3 3,485 Último mensaje 25 Enero 2021, 18:31 pm
por Tachikomaia
Mostrar ReporteView Local
.NET (C#, VB.NET, ASP)
rigorvzla 0 1,627 Último mensaje 8 Abril 2021, 17:52 pm
por rigorvzla
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines