Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - z3nth10n

#471
Hola buenas, pues he decido hacer una API para un servicio un tanto especial, tan especial que no me deja manejar ni MySQL ni PHP, por tanto tengo que mandar todas las peticiones a mi página usando JS...

Entonces, ahora mismo lo hago de la siguiente manera:

File.js
====

Código (javascript) [Seleccionar]
var key = "md5 string";

function sendToDB(data) {
accedo al php con un post => sendpost("file.php?key=key&domain="+location.hostname+"&data=data");
}


File.php
=====

Código (PHP) [Seleccionar]
$domain = @$_GET['domain'];
$credentials = mysqli_fetch_array(mysqli_query("SELECT * FROM clientes WHERE domain = $domain", $conn));

if($key == $credentials['key']) {
//Allow access and send data...
$data = @$_GET['data'];
mysqli_query("ENVIAR INFO A LA DB");
}


Entonces eso va genial para las injections ya que si paso la "data" tal como viene, pues apaga y vámonos...

Y como no lo puedo hacer de otra manera, lo único que se me ha ocurrido es enviar la información ("data") de forma cifrada o bien en Base64 o serializando...

No se os ocurre nada más seguro que eso? Quizás por la parte de PHP me puedo proteger más y a parte de usar un mysqli_real_escape_string no se me ocurre nada más... Qué me recomendáis?

Un saludo.
#472
Cita de: peib0l en 16 Agosto 2014, 11:38 AM


Y lo mejor es pensar que hay gente a la que le pasa... :xD :xD




Otra de LOL...

#473
Bueno, como siempre se agradecen sugerencias... Acabo de editar el código y sí, ese indentador no es mio, y la verdad es que tampoco me preocupe mucho, como vi que funciono la primera vez pues no le presté mucha atención...

Ahora como verás me he pasado poniendo usings, pero bueno >:D
#474
Muy buenas, después de estar bastante tiempo sin subir nada aquí tengo una cosita interesante :P

Creo que algunas de estas utilidades están ya presentes dentro de lo que es la super colección de Elektro, pero bueno supongo que un indentador XML nunca se ha visto por aquí así que aquí va:

Código (VBNET) [Seleccionar]
Imports System.IO
Imports System.Xml
Imports System.Xml.Serialization

Public Class XMLTools

   Public Shared Function Serialize(Of T)(value As T, Optional ByVal indented As Boolean = False) As String
       If value Is Nothing Then
           Throw New Exception("XMLSerializer - The value passed is null!")
           Return ""
       End If
       Try

           Dim xmlserializer As New XmlSerializer(GetType(T))
           Dim serializeXml As String = ""

           Using stringWriter As New StringWriter()

               Using writer As XmlWriter = XmlWriter.Create(stringWriter)
                   xmlserializer.Serialize(writer, value)
                   serializeXml = stringWriter.ToString()
               End Using

               If indented Then
                   serializeXml = Beautify(serializeXml)
               End If

           End Using

           Return serializeXml
       Catch ex As Exception
           Throw New Exception(ex.Message)
           Return ""
       End Try
   End Function

   Public Shared Function Deserialize(Of T)(value As String) As T

       Try
           Dim returnvalue As New Object()
           Dim xmlserializer As New XmlSerializer(GetType(T))
           Dim reader As TextReader = New StringReader(value)

           returnvalue = xmlserializer.Deserialize(reader)

           reader.Close()
           Return DirectCast(returnvalue, T)
       Catch ex As Exception
           Throw New Exception(ex.Message)
           Return Nothing
       End Try

   End Function

   Public Shared Sub SerializeToFile(Of T)(value As T, filePath As String, Optional ByVal indented As Boolean = False)
       If value Is Nothing Then
           Throw New Exception("XMLSerializer - The value passed is null!")
       End If
       Try
           Dim xmlserializer As New XmlSerializer(GetType(T))
           Using fileWriter As StreamWriter = New StreamWriter(filePath)
               If indented Then
                   Using stringWriter As New StringWriter()
                       Using writer As XmlWriter = XmlWriter.Create(stringWriter)
                           xmlserializer.Serialize(writer, value)
                           fileWriter.WriteLine(Beautify(stringWriter.ToString()))
                       End Using
                   End Using
               Else
                   Using writer As XmlWriter = XmlWriter.Create(fileWriter)
                       xmlserializer.Serialize(writer, value)
                   End Using
               End If
           End Using

       Catch ex As Exception
           Throw New Exception(ex.Message)
       End Try
   End Sub

   Public Shared Function DeserializeFromFile(Of T)(filePath As String) As T

       Try
           Dim returnvalue As New Object()
           Dim xmlserializer As New XmlSerializer(GetType(T))
           Using reader As TextReader = New StreamReader(filePath)
               returnvalue = xmlserializer.Deserialize(reader)
           End Using
           Return DirectCast(returnvalue, T)
       Catch ex As Exception
           Throw New Exception(ex.Message)
           Return Nothing
       End Try

   End Function

   Public Shared Function Beautify(obj As Object) As String
       Dim doc As New XmlDocument()
       If obj.[GetType]() Is GetType(String) Then
           If Not [String].IsNullOrEmpty(DirectCast(obj, String)) Then
               Try
                   doc.LoadXml(DirectCast(obj, String))
               Catch ex As Exception
                   Throw New Exception("XMLIndenter - Wrong string format! [" + ex.Message & "]")
                   Return ""
               End Try
           Else
               Throw New Exception("XMLIndenter - String is null!")
               Return ""
           End If
       ElseIf obj.[GetType]() Is GetType(XmlDocument) Then
           doc = DirectCast(obj, XmlDocument)
       Else
           Throw New Exception("XMLIndenter - Not supported type!")
           Return ""
       End If
       Dim returnValue As String = ""
       Using w As New MemoryStream()
           Using writer As New XmlTextWriter(w, Encoding.Unicode)
               writer.Formatting = Formatting.Indented
               doc.WriteContentTo(writer)

               writer.Flush()
               w.Seek(0L, SeekOrigin.Begin)

               Using reader As New StreamReader(w)
                   returnValue = reader.ReadToEnd()
               End Using
           End Using
       End Using
   End Function

End Class


Un saludo.
#475
Dudas Generales / Re: dudas internet
24 Mayo 2014, 12:22 PM
A lo mejor es eso lo que te consume mucho ancho de banda ;)
#476
jajaja Que va, solo lo digo por si queréis hablar con más gente ;) También podría haber mandado os links del IRC y TS3 pero no me los se... :rolleyes:
#477
EHN tiene IRC, TS3, hasta un grupo que cree yo por Skype...

Si queréis meteros, pues mi Skype es "ikillnukes" ;)
#478
Antes el de UNDER también salia repetido :rolleyes:
#479
Cuando sea ENH-DEV 2014... :-X
#480
Hardware / Re: ¿Portátil o torre?
1 Mayo 2014, 00:05 AM
Según cuanta potencia necesites, en general, no siempre las torres suelen tener más potencia y duran más... Si vas a hacer cosas en 3D una torre es la mejor opción.

Un saludo.