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

 

 


Tema destacado: Curso de javascript por TickTack


  Mostrar Mensajes
Páginas: 1 ... 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 [662] 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 ... 1236
6611  Programación / .NET (C#, VB.NET, ASP) / Re: C# Identificar usuario WindowsIdentity en: 24 Septiembre 2014, 11:23 am
Con la Class WindowsIdentity no vas a conseguir nada, el método GetCurrent devuelve el usuario local, y debes conocer el nombre del usuario (o el UPN si no formas parte de un dominio) para identificar un usuario usando el Constructor de dicha Class.

Aparte de eso, un FilesystemWatcher no recibe ni devuelve ningún tipo de información sobre el usuario en cuestión, según parece es una tarea bastante compleja de llevar a cabo, tienes mucha información sobre esto en los resultados de Google:

NTFS doesn't track who deletes, renames, or modifies a file, so there's no way you can get the username. It only keeps track of who OWNS the file.

No, it's not possible, the NTFS or FAT file system which is what Windows uses doesn't record this information. The best you could get about a file is last time it was changed.

First off, you'll need to devise some way of determining whether the changes to a file were made locally or remotely

The only possibilities I can think of would be the NetFileEnum and NetFileGetInfo API function calls

This isn't currently possible with the current implementations of the FileSystemWatcher as it does not receive this type of information when a file is deleted, or anything about a file changes.
You would need to use Win32 API calls, if it's possible at all. I'm not sure which APIs you would need to use,
but you will end up essentially writing your own version of a file system watcher

I was looking for the same thing today. I found something that will work.
See here: http://stackoverflow.com/questions/7861512/get-username-of-an-accesed-file

Keep in mind, auditing must be enabled for the folder.



La información de la función NetFileGetInfo es muy escasa así que no puedo mostrarte un ejemplo funcional (tampoco se si funcionaría, solo especulan por internet).
( http://msdn.microsoft.com/en-us/library/windows/desktop/bb525379%28v=vs.85%29.aspx )

Puedes probar la siguiente solución (ya no recuerdo de donde obtuve el código) sacada de: http://stackoverflow.com/questions/11660235/find-out-usernamewho-modified-file-in-c-sharp, pero personalmente y al menos en Windows 8.1 a mi me devuelve el grupo de usuarios (Administradores), no el usuario (Administrador).

La versión en VB.NET
Código
  1. Imports System.Text
  2. Imports System.IO
  3.  
  4. Public Class Form1
  5.  
  6.    Private Function GetSpecificFileProperties(file As String, ParamArray indexes As Integer()) As String
  7.  
  8.        Dim fileName As String = Path.GetFileName(file)
  9.        Dim folderName As String = Path.GetDirectoryName(file)
  10.        Dim shell As New Shell32.Shell()
  11.        Dim objFolder As Shell32.Folder
  12.        objFolder = shell.[NameSpace](folderName)
  13.        Dim sb As New StringBuilder()
  14.        For Each item As Shell32.FolderItem2 In objFolder.Items()
  15.            If fileName = item.Name Then
  16.                For i As Integer = 0 To indexes.Length - 1
  17.                    sb.Append(objFolder.GetDetailsOf(item, indexes(i)) + ",")
  18.                Next
  19.                Exit For
  20.            End If
  21.        Next
  22.        Dim result As String = sb.ToString().Trim()
  23.        If result.Length = 0 Then
  24.            Return String.Empty
  25.        End If
  26.        Return result.Substring(0, result.Length - 1)
  27.  
  28.    End Function
  29.  
  30.    Private Sub FileSystemWatcher1_Changed(sender As Object, e As FileSystemEventArgs) _
  31.    Handles FileSystemWatcher1.Changed, FileSystemWatcher1.Created
  32.  
  33.        Dim filepath As String = e.FullPath
  34.  
  35.        Dim Type As String = GetSpecificFileProperties(filepath, 2)
  36.        Dim ObjectKind As String = GetSpecificFileProperties(filepath, 11)
  37.        Dim CreatedDate As DateTime = Convert.ToDateTime(GetSpecificFileProperties(filepath, 4))
  38.        Dim LastModifiedDate As DateTime = Convert.ToDateTime(GetSpecificFileProperties(filepath, 3))
  39.        Dim LastAccessDate As DateTime = Convert.ToDateTime(GetSpecificFileProperties(filepath, 5))
  40.        Dim LastUser As String = GetSpecificFileProperties(filepath, 10)
  41.        Dim ComputerName As String = GetSpecificFileProperties(filepath, 53)
  42.        Dim FileSize As String = GetSpecificFileProperties(filepath, 1)
  43.  
  44.        Debug.WriteLine(LastUser)
  45.        Debug.WriteLine(ComputerName)
  46.  
  47.    End Sub
  48.  
  49. End Class



Esta parece ser una solución, aunque personalmente no la he consguido hacer funcionar:
http://vbcity.com/forums/p/133307/698930.aspx#698930
+
Use code posted by dave4dl and update declare struct FILE_INFO_3 as following, you can monitor user name of create and update file action(It is like to combination of FileSystemWatcher and OpenFiles.exe's functions of FileSharing Server)
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct FILE_INFO_3
{
    public int fi3_id;
    public int fi3_permission;
    public int fi3_num_locks;
    [MarshalAs(UnmanagedType.LPWStr)]
    public string fi3_pathname;
    [MarshalAs(UnmanagedType.LPWStr)]
    public string fi3_username;
}

Saludos.
6612  Sistemas Operativos / GNU/Linux / Re: Ayuda con un script en BASH en: 24 Septiembre 2014, 10:04 am
No conozco mucho de Bash, ¿pero has buscado aquí?: http://bit.ly/1CfikYd

Saludos!
6613  Programación / .NET (C#, VB.NET, ASP) / ¿Alternativa al atributo RangeAttribute de ASP.NET? en: 23 Septiembre 2014, 21:49 pm
¿Alguien conoce alguna alternativa al > RangeAttribute <, para WindowsForms?, me parece que .Net Framework no expone nada parecido más que para ASP.Net, pero no estoy seguro de ello.

Leí acerca de como implementar este atributo usando la librería > PostSharp <, es muy sencillo implementarlo de forma básica la verdad, pero es un producto de pago y la "medicina" no funciona muy bien, de todas formas muestro un ejemplo por si a alguien le sirve:

Código
  1. ''' <summary>
  2. ''' Specifies the numeric range constraints for the value of a data field.
  3. ''' </summary>
  4. <Serializable>
  5. Class RangeAttribute : Inherits PostSharp.Aspects.LocationInterceptionAspect
  6.  
  7.    ''' <summary>
  8.    ''' The minimum range value.
  9.    ''' </summary>
  10.    Private min As Integer
  11.  
  12.    ''' <summary>
  13.    ''' The maximum range value.
  14.    ''' </summary>
  15.    Private max As Integer
  16.  
  17.    ''' <summary>
  18.    ''' Initializes a new instance of the <see cref="RangeAttribute" /> class.
  19.    ''' </summary>
  20.    ''' <param name="min">The minimum range value.</param>
  21.    ''' <param name="max">The maximum range value.</param>
  22.    Public Sub New(ByVal min As Integer, ByVal max As Integer)
  23.  
  24.        Me.min = min
  25.        Me.max = max
  26.  
  27.    End Sub
  28.  
  29.    ''' <summary>
  30.    ''' Method invoked <i>instead</i> of the <c>Set</c> semantic of the field or property to which the current aspect is applied,
  31.    ''' i.e. when the value of this field or property is changed.
  32.    ''' </summary>
  33.    ''' <param name="args">Advice arguments.</param>
  34.    Public Overrides Sub OnSetValue(ByVal args As PostSharp.Aspects.LocationInterceptionArgs)
  35.  
  36.        Dim value As Integer = CInt(args.Value)
  37.  
  38.        If value < min Then
  39.            value = min
  40.  
  41.        ElseIf value > max Then
  42.            value = max
  43.  
  44.        End If
  45.  
  46.        args.SetNewValue(value)
  47.  
  48.    End Sub
  49.  
  50. End Class

En fin, si hay que implementarlo por uno mismo sin la ayuda de herramientas de terceros pues se implementa desde cero, pero ni siquiera conozco que Class debería heredar para empezar a crear un atributo de metadatos parecido al RangeAttribute, que funcione en WinForms, apenas puedo encontrar información sobre esto en Google/MSDN y todo lo que encuentro es para ASP.Net.

PD: Actualmente hago la validación del rango en el getter/setter de las propiedades, así que eso no contaría como "alternativa" xD.

Cualquier información se agradece,
Saludos!
6614  Programación / .NET (C#, VB.NET, ASP) / Re: Una mano con este codigo. (array de byte dinamico) en: 23 Septiembre 2014, 13:37 pm
Porfavor, no reabrir temas resueltos para hacer comentarios OffTopic '¬¬ :P

PD: A mi tampoco me gusta el "antifaz" de VisualStudio que se puso el compañero KuB0x xD.

Tema cerrado.
6615  Foros Generales / Dudas Generales / Re: scrips en: 23 Septiembre 2014, 12:12 pm
El primer comentario de arriba está equivocado, un Script es un Script, froma parte del código fuente de una aplicación y precisamente por eso no debe significar que se le pueda dar un uso genérico a dicho Script, ya que la mayoría del código debería estar hardcodeado.

Deduzco que tú te estás refiriendo a los Code-Snippet, esta sería más o menos su definición:

¿Que es un Snippet?

Es un extracto de código que suele contener una o varias Subrutinas con el propósito de realizar una tarea específica,
cuyo código es reusable por otras personas y fácil de integrar con solamente copiar y pegar el contenido del Snippet.
( Fuente: http://en.wikipedia.org/wiki/Snippet_%28programming%29 )

Por supuesto en Google puedes encontrar muchas páginas que sirven como una especie de base de datos ya que se dedican a recopilar Snippets de todos o casi todos los lenguajes de programación y de cualquier temática, pero si tú ni siquiera espeficas el lenguaje cuando formulas este tipo de pregunta entonces no se que tipo de ayuda esperas, especifica el nombre del lenguaje seguido de la palabra "Snippets" en Google y hallarás lo que andas buscando.

De todas formas y por si te interesa, en el foro posteé un apartado para publicar Snippets de programación de los lenguajes VB.NET y C#, aquí los puedes ver (hay más de 710 en total):
· Librería de Snippets !! (Compartan aquí sus snippets)

Y el compañero IKillNukes hizo lo mismo en la sección de programación C/C++ del foro, puedes usar el buscador del foro.

Saludos.
6616  Foros Generales / Sugerencias y dudas sobre el Foro / Re: Spam en el foro en: 23 Septiembre 2014, 09:27 am
Son el clan de ASNOS

jajajaja, no demos más publicidad de la necesaria a los 'ASNO-DDoS Team', luego podrian crecerse xD.

Saludos!
6617  Foros Generales / Sugerencias y dudas sobre el Foro / Re: Spam en el foro en: 23 Septiembre 2014, 08:03 am
Hasta que no se conecte un mod-global o admin para eliminar los mensajes y/o banear al usuario... nada se puede hacer xD

PD: Yo borré bastantes mensajes de ese Bot en mis secciones

un saludo!
6618  Informática / Software / Re: restringir descargas en: 23 Septiembre 2014, 07:45 am
Gratis no creo que vayas a encontrar nada, pero puedes testear las versiones Trial.

· http://www.imlocknow.com/

· http://www.winability.com/how-to-stop-downloading-from-internet/

· http://www.allowblock.com/blockdownloads.html

· http://www.os-monitor.com/block-download.htm

· http://install-block.software.informer.com/

...y decenas más en Google.

PD: No he probado ningún Soft mencionado arriba.

Saludos!
6619  Foros Generales / Sugerencias y dudas sobre el Foro / Re: no puedo entrar a la web en: 22 Septiembre 2014, 15:54 pm
El foro ha estado inaccesible durante 30 minutos o más, acabo de poder entrar...

Ya da un poco de asco y verguenza ajena como ser humano este tipo de ataques al foro, que se compren una vida, que no nos tienen porque molestar a los demás.

Esto es lo que pienso de estos infraseres tocapelotas a nivel experto que hacen DDOS al foro:





PD: El meme no lo hice yo.
PD2: El retrasómetto tampoco xD.


Un saludo!
6620  Programación / Programación General / Re: ¿Cuál es el nombre de las etiquetas o códigos con %? en: 22 Septiembre 2014, 09:16 am
Buenas

Las preguntas de Python deben ir en la sección de Scripting.

Python las denomina en la documentación como "Directivas":

· Time.strftime(format[, t])

Saludos
Páginas: 1 ... 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 [662] 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines