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

 

 


Tema destacado: Introducción a Git (Primera Parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)
0 Usuarios y 2 Visitantes están viendo este tema.
Páginas: 1 ... 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 [20] 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 ... 59 Ir Abajo Respuesta Imprimir
Autor Tema: Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)  (Leído 484,456 veces)
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.809



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #190 en: 20 Junio 2013, 16:20 pm »

GeoLocalizar una IP:

Código
  1. #Region " GeoLocation "
  2.  
  3. ' [ GeoLocation ]
  4. '
  5. ' // By Elektro H@cker
  6. '
  7. ' Examples :
  8. '
  9. ' Dim GeoInfo As GeoLocation.GeoInfo = GeoLocation.Locate("84.126.113.11")
  10. ' Dim GeoInfo As GeoLocation.GeoInfo = GeoLocation.Locate("84.126.113.11.dyn.user.ono.com")
  11. ' MsgBox(GeoInfo.Country) ' result: Spain
  12. ' MsgBox(GeoInfo.City)    ' Result: Valencia
  13.  
  14. Public Class GeoLocation
  15.  
  16.    Public Class GeoInfo
  17.        Public Property Latitude() As String
  18.        Public Property Lognitude() As String
  19.        Public Property City() As String
  20.        Public Property State() As String
  21.        Public Property Country() As String
  22.        Public Property Host() As String
  23.        Public Property Ip() As String
  24.        Public Property Code() As String
  25.    End Class
  26.  
  27.    Public Shared Function Locate(ByVal IP As String) As GeoInfo
  28.  
  29.        Try
  30.  
  31.            Dim request = TryCast(Net.WebRequest.Create(New Uri("http://www.geoiptool.com/data.php/en/?IP=" & IP)), Net.HttpWebRequest)
  32.  
  33.            If request IsNot Nothing Then
  34.  
  35.                request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727)"
  36.  
  37.                Dim _geoloc As New GeoInfo
  38.  
  39.                Using webResponse = TryCast(request.GetResponse(), Net.HttpWebResponse)
  40.                    If webResponse IsNot Nothing Then
  41.  
  42.                        Using reader = New IO.StreamReader(webResponse.GetResponseStream())
  43.  
  44.                            Dim doc = New Xml.XmlDocument()
  45.  
  46.                            doc.Load(reader)
  47.  
  48.                            Dim nodes = doc.GetElementsByTagName("marker")
  49.  
  50.                            Dim marker = TryCast(nodes(0), Xml.XmlElement)
  51.  
  52.                            _geoloc.City = marker.GetAttribute("city")
  53.                            _geoloc.Country = marker.GetAttribute("country")
  54.                            _geoloc.Code = marker.GetAttribute("code")
  55.                            _geoloc.Host = marker.GetAttribute("host")
  56.                            _geoloc.Ip = marker.GetAttribute("ip")
  57.                            _geoloc.Latitude = marker.GetAttribute("lat")
  58.                            _geoloc.Lognitude = marker.GetAttribute("lng")
  59.  
  60.                            Return _geoloc
  61.  
  62.                        End Using
  63.  
  64.                    End If
  65.                End Using
  66.            End If
  67.  
  68.            Return New GeoInfo()
  69.  
  70.        Catch ex As Exception
  71.            Throw New Exception(ex.Message)
  72.        End Try
  73.  
  74.    End Function
  75.  
  76. End Class
  77.  
  78. #End Region


En línea

Novlucker
Ninja y
Colaborador
***
Desconectado Desconectado

Mensajes: 10.683

Yo que tu lo pienso dos veces


Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #191 en: 20 Junio 2013, 17:32 pm »

Implementación en C#
Código
  1.    public class GeoLocation
  2.    {
  3.        [XmlRoot("markers")]
  4.        public class markers
  5.        {
  6.            [XmlElement("marker")]
  7.            public List<GeoIfo> marker { get; set; }
  8.        }
  9.  
  10.        public class GeoIfo
  11.        {
  12.            [XmlAttribute("lat")]
  13.            public string Latitude { get; set; }
  14.            [XmlAttribute("lng")]
  15.            public string Longitude { get; set; }
  16.            [XmlAttribute("city")]
  17.            public string City { get; set; }
  18.            [XmlAttribute("country")]
  19.            public string Country { get; set; }
  20.            [XmlAttribute("host")]
  21.            public string Host { get; set; }
  22.            [XmlAttribute("ip")]
  23.            public string Ip { get; set; }
  24.            [XmlAttribute("code")]
  25.            public string Code { get; set; }
  26.        }
  27.  
  28.        public static GeoIfo Locate(string IP)
  29.        {
  30.            WebClient client = new WebClient();
  31.            string xml = client.DownloadString(string.Format("{0}{1}", "http://www.geoiptool.com/data.php/en/?IP=", IP));
  32.            XmlSerializer serializer = new XmlSerializer(typeof(markers));
  33.            markers geoInfo;
  34.  
  35.            using (StringReader reader = new StringReader(xml))
  36.            {
  37.                geoInfo = (markers)serializer.Deserialize(reader);
  38.            }
  39.  
  40.            return geoInfo.marker.First();
  41.        }
  42.    }


En línea

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
z3nth10n


Desconectado Desconectado

Mensajes: 1.583


"Jack of all trades, master of none." - Zenthion


Ver Perfil WWW
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #192 en: 20 Junio 2013, 17:39 pm »

Ala, ya si se puede decir que Nov a "ayudado" :P



Googleando un poquito he encontrado esto:

Código
  1. Public Class Form1
  2.    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  3.        WebBrowser1.Navigate("http://google.com")
  4.    End Sub
  5.    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
  6.        AddHandler WebBrowser1.Document.Click, AddressOf getClickedElement
  7.    End Sub
  8.    Private Sub getClickedElement(ByVal sender As Object, ByVal e As HtmlElementEventArgs)
  9.        With WebBrowser1.Document.GetElementFromPoint(e.ClientMousePosition)
  10.            Dim selectedHtmlElement_ID As String = .GetAttribute("id").ToLower
  11.            Dim selectedHtmlElement_NAME As String = .GetAttribute("name").ToLower
  12.            MsgBox("ID: " & selectedHtmlElement_ID & vbNewLine & " --- Name: " & selectedHtmlElement_NAME)
  13.        End With
  14.    End Sub
  15. End Class

Básicamente podemos sacar el Name y la Id del elemento clicado a través de un MsgBox.

Un saludo. :)
Que os parece? :P
« Última modificación: 20 Junio 2013, 19:16 pm por Ikillnukes » En línea


Interesados hablad por Discord.
Novlucker
Ninja y
Colaborador
***
Desconectado Desconectado

Mensajes: 10.683

Yo que tu lo pienso dos veces


Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #193 en: 20 Junio 2013, 19:27 pm »

Ala, ya si se puede decir que Nov a "ayudado" :P

Es que insisto, muchos códigos si me parecen útiles, pero otros se me hacen demasiado evidentes como para tener que buscarlos en algún sitio, demoro menos codeandolo, ej;
"Get_Method", y "Comprueba si un numero es divisible por otro": https://foro.elhacker.net/net/libreria_de_snippets_posteen_aqui_sus_snippets-t378770.0.html;msg1857426#msg1857426
"Download_URL_SourceCode": https://foro.elhacker.net/net/libreria_de_snippets_posteen_aqui_sus_snippets-t378770.0.html;msg1856078#msg1856078
"Elimina un Item de un Array": https://foro.elhacker.net/net/libreria_de_snippets_posteen_aqui_sus_snippets-t378770.0.html;msg1856079#msg1856079

Saludos
En línea

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
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.809



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #194 en: 20 Junio 2013, 20:26 pm »

Un Bot para IRC.

No soy experto en IRC, lo hice basándome en wl webchat de freenode, pero imagino que funcionará en todos los canales de IRC.

...Extender y/o modificar el código como querais, esto solo e sun ejemplo, dejar volar vuestra imaginación:


Un ejemplo de uso:

Código
  1. Public Class Form1
  2.  
  3.    Dim IRC_Thread_Var As Threading.Thread = New Threading.Thread(AddressOf IRC_Thread)
  4.  
  5.    Private Sub Form1_shown(sender As Object, e As EventArgs) Handles MyBase.Shown
  6.        IRC_Thread_Var = New Threading.Thread(AddressOf IRC_Thread)
  7.        IRC_Thread_Var.Start()
  8.    End Sub
  9.  
  10.    Sub IRC_Thread()
  11.        IRC_Bot.Connect("irc.freenode.org", "#ircehn", "ElektroBot")
  12.    End Sub
  13.  
  14. End Class

...La class del Bot:
Código
  1. Public Class IRC_Bot
  2.  
  3.    ' Channel Moderators
  4.    Public Shared Gods As String() = "Elektro Elektro-H Elektro-H_ Drvy kili4n Ikillnukes Caster_ OmarHack OmarHack_ Carloswaldo _0xDani".Split(ChrW(32)).ToArray
  5.  
  6.    ' Commands
  7.    Private Shared Line As String = Nothing
  8.    Private Shared Name As String = Nothing
  9.    Private Shared IP As String = Nothing
  10.    Private Shared Command As String = Nothing
  11.    Private Shared Argument As String = Nothing
  12.  
  13.    ' Bot Status
  14.    Public Shared Activated As Boolean = True
  15.    Private Shared Elapsed_Time As New Stopwatch
  16.    Private Shared Total_Messages As Int64 = 0
  17.  
  18.    ' Connection
  19.    Private Shared Ident_Listener As Net.Sockets.TcpListener = Nothing
  20.    Private Shared Ident_Client As Net.Sockets.TcpClient = Nothing
  21.    Private Shared Ident_NetworkStream As Net.Sockets.NetworkStream = Nothing
  22.    Private Shared Ident_Reader As IO.StreamReader = Nothing
  23.    Private Shared Ident_Writer As IO.StreamWriter = Nothing
  24.    Private Shared Ident_ResponseString As String = Nothing
  25.    Private Shared TCP_client As Net.Sockets.TcpClient = Nothing ' Main connection to the IRC network.
  26.    Private Shared Network_Stream As Net.Sockets.NetworkStream = Nothing ' Break TCP connection down to a network stream.
  27.    Private Shared IRC_Reader As IO.StreamReader = Nothing ' Stream to read messages from the Server.
  28.    Private Shared IRC_Writer As IO.StreamWriter = Nothing ' Stream to write messages to the server.
  29.  
  30.    ' To attach Console (If needed)
  31.    ' Private Declare Function AllocConsole Lib "kernel32.dll" () As Boolean
  32.  
  33.    Public Shared Sub Connect(ByVal Server As String, _
  34.                       ByVal Channel As String, _
  35.                       ByVal NickName As String, _
  36.                       Optional ByVal Port As Int32 = 6667, _
  37.                       Optional ByVal RealName As String = "ElektroBot", _
  38.                       Optional ByVal UserName As String = "ElektroHacker")
  39.  
  40.        ' AllocConsole() '  Attach Console (If needed)
  41.  
  42.        ' Change CMD Window Size
  43.        Console.SetWindowSize(200, 60)
  44.  
  45.        Try
  46.  
  47.            ' Create Connection
  48.            Write("Creating Connection...", ConsoleColor.Yellow)
  49.            TCP_client = New Net.Sockets.TcpClient(Server, Port)
  50.            Network_Stream = TCP_client.GetStream
  51.            IRC_Reader = New IO.StreamReader(Network_Stream)
  52.            IRC_Writer = New IO.StreamWriter(Network_Stream)
  53.            If Not IRC_Writer.AutoFlush Then IRC_Writer.AutoFlush = True
  54.  
  55.            ' Set name
  56.            Write("Setting up name...", ConsoleColor.Yellow)
  57.            IRC_Writer.WriteLine(String.Format("USER {0} {1} * :{2}", UserName, 0, RealName))
  58.  
  59.            ' Set Nickname
  60.            Write("Setting Nickname...", ConsoleColor.Yellow)
  61.            IRC_Writer.WriteLine(String.Format("NICK {0}", NickName))
  62.  
  63.            ' Join Room
  64.            Write("Joining Room...", ConsoleColor.Yellow)
  65.            IRC_Writer.WriteLine(String.Format("JOIN {0}", Channel))
  66.  
  67.            ' Check Ident connection
  68.            Write("Checking Ident connection...", ConsoleColor.Yellow)
  69.            Ident_Listener = New Net.Sockets.TcpListener(Net.IPAddress.Any, 113)
  70.            Ident_Listener.Start()
  71.            Ident_Client = Ident_Listener.AcceptTcpClient
  72.            Ident_Listener.Stop()
  73.            Ident_NetworkStream = Ident_Client.GetStream
  74.            Ident_Reader = New IO.StreamReader(Ident_NetworkStream)
  75.            Ident_ResponseString = Ident_Reader.ReadLine
  76.            Write("Ident got: " & Ident_ResponseString, ConsoleColor.Cyan)
  77.            Ident_Writer = New IO.StreamWriter(Ident_NetworkStream)
  78.            If Not Ident_Writer.AutoFlush Then Ident_Writer.AutoFlush = True
  79.            Ident_Writer.WriteLine(String.Format("{0} : USERID : WINDOWS 7 : {1}", Ident_ResponseString, UserName))
  80.  
  81.            ' Read messages
  82.            Write("Reading messages...", ConsoleColor.Yellow)
  83.            Elapsed_Time.Start()
  84.  
  85.            While True
  86.  
  87.                ' Sum the total received messages
  88.                Total_Messages += 1
  89.  
  90.                ' Get the IRC line to read
  91.                Line = IRC_Reader.ReadLine
  92.  
  93.                ' Print the IRC line
  94.                Write(Line, ConsoleColor.Gray)
  95.  
  96.                ' Get User Name
  97.                Try : Name = Line.Split("!").First.Substring(1, Line.Split("!").First.Length - 1)
  98.                Catch : Name = Nothing
  99.                End Try
  100.  
  101.                ' Get User IP
  102.                Try : IP = Line.Split(" ").First.Split("/").Last.Replace("ip.", "")
  103.                Catch : IP = Nothing
  104.                End Try
  105.  
  106.                ' Get User Command
  107.                Try : Command = Line.Split(" ")(3).Substring(1, Line.Split(" ")(3).Length - 1).ToLower
  108.                Catch : Command = Nothing
  109.                End Try
  110.  
  111.                ' Get the command argument
  112.                Try : Argument = Line.Split(" ")(4)
  113.                Catch : Argument = Nothing
  114.                End Try
  115.  
  116.                    ' IRC Ping-Pong
  117.                    if line.tolower.startswith("ping") then
  118.                        Write("Answering Ping with Pong...", ConsoleColor.Yellow)
  119.                        Write("PONG " & Line, ConsoleColor.Cyan)
  120.                        IRC_Writer.WriteLine("PONG " & Line)
  121.                    end if
  122.  
  123.                ' Parse commands
  124.                Select Case Command
  125.  
  126.                        ' Help
  127.                    Case "!?", "!ayuda"
  128.  
  129.                        If Line.ToLower.Contains(Channel.ToLower) Then
  130.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1}      ", Name, "[+] Comandos públicos:"))
  131.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} | {2}", Name, "!? | !ayuda      ", "Muestra esta ayuda."))
  132.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} | {2}", Name, "!reglas          ", "Muestra las reglas de la sala."))
  133.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} | {2}", Name, "!reglasehn       ", "Muestra las reglas de ElHacker.Net."))
  134.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} | {2}", Name, "!status          ", "Muestra el estado del Bot."))
  135.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} | {2}", Name, "!Whois (IP)      ", "Muestra información geográfica de una IP."))
  136.  
  137.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1}      ", Name, "[+] Comandos privados:"))
  138.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} | {2}", Name, "!op              ", "Te otorga el estado de OP."))
  139.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} | {2}", Name, "!op(+|-) (NOMBRE)", "Otorga o elimina el estado de OP a un usuario."))
  140.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} | {2}", Name, "!bot (ON|OFF)    ", "Activa o Desactiva el Bot."))
  141.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} | {2}", Name, "!q | !quit       ", "Desconecta al Bot."))
  142.                        End If
  143.  
  144.                        ' Room Rules
  145.                    Case "!reglas"
  146.  
  147.                        If Line.ToLower.Contains(Channel.ToLower) Then
  148.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1}", Name, "[+] Reglas de " & Channel))
  149.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1}", Name, "1. Respetar a los usuarios y no ofender de ninguna manera."))
  150.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1}", Name, "2. No preguntar como puedes hackear a personas ajenas."))
  151.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1}", Name, "3. No compartir material pornográfico o difundir la pederástia o cosas parecidas."))
  152.                        End If
  153.  
  154.                        ' EHN Rules
  155.                    Case "!reglasehn"
  156.  
  157.                        If Line.ToLower.Contains(Channel.ToLower) Then
  158.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1}", Name, "[+] Reglas de ElHacker.Net: http://foro.elhacker.net/reglas"))
  159.                        End If
  160.  
  161.                        ' Geo-Locate IP
  162.                    Case "!whois"
  163.  
  164.                        'If Line.ToLower.Contains(Channel.ToLower) Then _
  165.                        'AndAlso Activated Then
  166.  
  167.                        'Dim GeoInfo As GeoLocation.GeoInfo = GeoLocation.Locate(Argument)
  168.                        'IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "[+] Información geográfica de ", Argument))
  169.                        'IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "País..:", GeoInfo.Country))
  170.                        'IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "Ciudad:", GeoInfo.City))
  171.                        'IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "Código:", GeoInfo.Code))
  172.                        'IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "Host..:", GeoInfo.Host))
  173.                        'IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "Ip....:", GeoInfo.Ip))
  174.                        'GeoInfo = Nothing
  175.  
  176.                        ' End If
  177.  
  178.                        ' Give own OP+
  179.                    Case "!op"
  180.  
  181.                        If Gods.Contains(Name) _
  182.                        AndAlso Line.ToLower.Contains(Channel.ToLower) _
  183.                        AndAlso Activated Then
  184.  
  185.                            IRC_Writer.WriteLine(String.Format("MODE {0} +o {1}", Channel, Name))
  186.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} :{1} {2}", Channel, Name, "se ha convertido en OP."))
  187.  
  188.                        ElseIf Not Gods.Contains(Name) _
  189.                        AndAlso Line.ToLower.Contains(Channel.ToLower) _
  190.                        AndAlso Activated Then
  191.  
  192.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} :{1} {2}", Channel, Name, "no tienes privilegios para ser OP."))
  193.  
  194.                        End If
  195.  
  196.                        ' Give Op+ to a user
  197.                    Case "!op+"
  198.  
  199.                        If Gods.Contains(Name) _
  200.                        AndAlso Line.ToLower.Contains(Channel.ToLower) _
  201.                        AndAlso Activated Then
  202.  
  203.                            IRC_Writer.WriteLine("MODE {0} +o {1}", Channel, Argument)
  204.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} :{1} {2} {3}", Channel, Name, "concedió OP a", Argument))
  205.  
  206.                        ElseIf Not Gods.Contains(Name) _
  207.                        AndAlso Line.ToLower.Contains(Channel.ToLower) _
  208.                        AndAlso Activated Then
  209.  
  210.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} :{1} {2}", Channel, Name, "no tienes privilegios para conceder OP."))
  211.  
  212.                        End If
  213.  
  214.                        ' Give Op- to a user
  215.                    Case "!op-"
  216.  
  217.                        If Gods.Contains(Name) _
  218.                        AndAlso Line.ToLower.Contains(Channel.ToLower) _
  219.                        AndAlso Activated Then
  220.  
  221.                            IRC_Writer.WriteLine("MODE {0} -o {1}", Channel, Argument)
  222.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} :{1} {2} {3}", Channel, Name, "denegó OP a", Argument))
  223.  
  224.                        ElseIf Not Gods.Contains(Name) _
  225.                        AndAlso Line.ToLower.Contains(Channel.ToLower) _
  226.                        AndAlso Activated Then
  227.  
  228.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} :{1} {2}", Channel, Name, "no tienes privilegios para denegar OP."))
  229.  
  230.                        End If
  231.  
  232.                        ' Bot ON/OFF
  233.                    Case "!bot"
  234.  
  235.                        If Gods.Contains(Name) _
  236.                        AndAlso Line.ToLower.Contains(Channel.ToLower) Then
  237.  
  238.                            Select Case Argument.ToLower
  239.                                Case "on"
  240.                                    Activated = True
  241.                                    Write("Bot status changed to: Enabled", ConsoleColor.Cyan)
  242.                                Case "off"
  243.                                    Activated = False
  244.                                    Write("Bot status changed to: Disabled", ConsoleColor.Cyan)
  245.                            End Select
  246.  
  247.                        ElseIf Not Gods.Contains(Name) _
  248.                        AndAlso Line.ToLower.Contains(Channel.ToLower) Then
  249.  
  250.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} :{1} {2}", Channel, Name, "no tienes privilegios de OP."))
  251.  
  252.                        End If
  253.  
  254.                        ' Bot Status
  255.                    Case "!status"
  256.  
  257.                        If Line.ToLower.Contains(Channel.ToLower) Then
  258.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1}    ", Name, "[+] Status del Bot"))
  259.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "Soy propiedad de......:", "Elektro-H"))
  260.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "Versión de mi sistema.:", "0.2"))
  261.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "Tiempo total online...:", Elapsed_Time.Elapsed.Hours & " H, " & Elapsed_Time.Elapsed.Minutes & " M, " & Elapsed_Time.Elapsed.Seconds & " S"))
  262.                            IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "Mensajes procesados...:", Total_Messages))
  263.                        End If
  264.  
  265.                        ' Quit
  266.                    Case "!q", "!quit"
  267.  
  268.                        If Gods.Contains(Name) _
  269.                        AndAlso Line.ToLower.Contains(Channel.ToLower) _
  270.                        AndAlso Activated Then
  271.  
  272.                            IRC_Writer.WriteLine("QUIT")
  273.                            Write("Exiting...", ConsoleColor.Yellow)
  274.                            Exit Sub
  275.  
  276.                        End If
  277.  
  278.                End Select
  279.  
  280.            End While
  281.  
  282.        Catch ex As Exception
  283.            Write("Error: " & ex.Message, ConsoleColor.Red)
  284.            IRC_Writer.WriteLine("QUIT")
  285.  
  286.        Finally
  287.            IRC_Reader.Dispose()
  288.            IRC_Writer.Dispose()
  289.            Network_Stream.Dispose()
  290.  
  291.        End Try
  292.  
  293.    End Sub
  294.  
  295.    Private Shared Sub Write(ByVal Text As String, _
  296.                                 Optional ByVal ForeColor As System.ConsoleColor = ConsoleColor.White, _
  297.                                 Optional ByVal BackColor As System.ConsoleColor = ConsoleColor.Black)
  298.  
  299.        Dim Current_ForegroundColor As ConsoleColor = Console.ForegroundColor
  300.        Dim Current_BackgroundColor As ConsoleColor = Console.BackgroundColor
  301.  
  302.        Console.ForegroundColor = ForeColor
  303.        Console.BackgroundColor = BackColor
  304.        Console.WriteLine(Text & vbNewLine)
  305.  
  306.        Console.ForegroundColor = Current_ForegroundColor
  307.        Console.BackgroundColor = Current_BackgroundColor
  308.  
  309.    End Sub
  310.  
  311. End Class
« Última modificación: 20 Junio 2013, 20:54 pm por EleKtro H@cker » En línea

z3nth10n


Desconectado Desconectado

Mensajes: 1.583


"Jack of all trades, master of none." - Zenthion


Ver Perfil WWW
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #195 en: 20 Junio 2013, 20:45 pm »

Muy buen code, y las captchas? :rolleyes:
En línea


Interesados hablad por Discord.
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.809



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #196 en: 20 Junio 2013, 21:38 pm »

y las captchas? :rolleyes:
El captcha te lo pide la web de freenode, no el protocolo IRC.
no es necesario, pruébalo xD...
« Última modificación: 20 Junio 2013, 22:08 pm por EleKtro H@cker » En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.809



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #197 en: 20 Junio 2013, 21:48 pm »

Implementación en C#

Gracias Nov
En línea

z3nth10n


Desconectado Desconectado

Mensajes: 1.583


"Jack of all trades, master of none." - Zenthion


Ver Perfil WWW
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #198 en: 20 Junio 2013, 22:12 pm »

El captcha te lo pide la web de freenode, no el protocolo IRC.
no es necesario, pruébalo xD...

Okey, gracias :)
En línea


Interesados hablad por Discord.
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.809



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #199 en: 22 Junio 2013, 20:28 pm »

Obtener en WinAmp el título o la ruta del archivo de la canción actual.

PD: Son códigos de VB6 que convertí a .NET (no todo...) con algo de ayuda.

Código
  1. #Region " WinAmp Info"
  2.  
  3. ' [ WinAmp Info ]
  4. '
  5. ' // By Elektro H@cker
  6. '
  7. ' Examples:
  8. ' MsgBox(WinAmp.Get_Title)    ' Result: Artist - Title
  9. ' MsgBox(WinAmp.Get_FileName) ' Result: C:\Title.ext
  10.  
  11. Public Class WinAmp
  12.  
  13.    Private Const WinampClassName As String = "Winamp v1.x"
  14.  
  15.    Private Declare Auto Function FindWindow Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
  16.    Private Declare Auto Function GetWindowText Lib "user32" (ByVal hwnd As IntPtr, ByVal lpString As String, ByVal cch As Integer) As Integer
  17.    Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, ByRef lpdwProcessId As Long) As Long
  18.    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
  19.    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  20.    Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, ByRef lpBuffer As Byte, ByVal nSize As Long, ByRef lpNumberOfBytesRead As Long) As Long
  21.    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
  22.  
  23.    Public Shared Function Get_Title() As String
  24.  
  25.        Dim hwnd As IntPtr = FindWindow(WinampClassName, vbNullString)
  26.  
  27.        Dim lpText As String = String.Empty
  28.        Dim strTitle As String = String.Empty
  29.  
  30.        Dim intLength As Integer = 0
  31.        Dim intName As Integer = 0
  32.        Dim intLeft As Integer = 0
  33.        Dim intRight As Integer = 0
  34.        Dim intDot As Integer = 0
  35.  
  36.        If hwnd.Equals(IntPtr.Zero) Then Return "WinAmp is not running"
  37.  
  38.        lpText = New String(Chr(0), 100)
  39.        intLength = GetWindowText(hwnd, lpText, lpText.Length)
  40.  
  41.        If (intLength <= 0) _
  42.        OrElse (intLength > lpText.Length) _
  43.        Then Return "Unknown"
  44.  
  45.        strTitle = lpText.Substring(0, intLength)
  46.        intName = strTitle.IndexOf(" - Winamp")
  47.        intLeft = strTitle.IndexOf("[")
  48.        intRight = strTitle.IndexOf("]")
  49.  
  50.        If (intName >= 0) _
  51.        AndAlso (intLeft >= 0) _
  52.        AndAlso (intName < intLeft) _
  53.        AndAlso (intRight >= 0) _
  54.        AndAlso (intLeft + 1 < intRight) _
  55.        Then Return strTitle.Substring(intLeft + 1, intRight - intLeft - 1)
  56.  
  57.        If (strTitle.EndsWith(" - Winamp")) _
  58.        AndAlso (strTitle.Length > " - Winamp".Length) _
  59.        Then strTitle = strTitle.Substring(0, strTitle.Length - " - Winamp".Length)
  60.  
  61.        intDot = strTitle.IndexOf(".")
  62.  
  63.        If (intDot > 0) _
  64.        AndAlso (IsNumeric(strTitle.Substring(0, intDot))) _
  65.        Then strTitle = strTitle.Remove(0, intDot + 1)
  66.  
  67.        Return strTitle.Trim
  68.  
  69.    End Function
  70.  
  71.    Public Shared Function Get_FileName() As String
  72.  
  73.        Dim lp As Long, lpWinamp As Long, iIndex As Long, PID As Long, bRet As Long, dwRead As Long
  74.        Dim Buffer(260) As Byte
  75.  
  76.        Dim hWndWinamp As IntPtr = FindWindow(WinampClassName, vbNullString)
  77.        If hWndWinamp = 0 Then Return Nothing
  78.  
  79.        iIndex = SendMessage(hWndWinamp, &H400, 0, 125)
  80.  
  81.        lp = SendMessage(hWndWinamp, &H400, iIndex, 211)
  82.        If lp = 0 Then Return Nothing
  83.  
  84.        Call GetWindowThreadProcessId(hWndWinamp, PID)
  85.  
  86.        lpWinamp = OpenProcess(&H10, 0, PID)
  87.        If lpWinamp = 0 Then Return Nothing
  88.  
  89.        bRet = ReadProcessMemory(lpWinamp, lp, Buffer(0), 260, dwRead)
  90.  
  91.        Call CloseHandle(lpWinamp)
  92.  
  93.        Return System.Text.UnicodeEncoding.Default.GetString(Buffer)
  94.  
  95.    End Function
  96.  
  97. End Class
  98.  
  99. #End Region
« Última modificación: 22 Junio 2013, 20:30 pm por EleKtro H@cker » En línea

Páginas: 1 ... 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 [20] 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 ... 59 Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines