Mostrando entradas con la etiqueta Visual Basic. Mostrar todas las entradas

Server Builder [VB6]

Hola a todos. En este tutorial les voy a enseñar a hacer un Builder para que puedan utilizarlo a la hora de programar un malware.
Les dejare un ejemplo bastante simple, y se los tratare de explicar lo mejor posible para que lo puedan entender sin problemas.
Primero debemos crear un nuevo proyecto con un EXE Estandar

Builder:
En el formulario colocaremos 2 TextBox y 1 Boton (Los labels son opcionales ya que no afectan al funcionamiento)
Y en su codigo lo siguiente:

Declaracion de variables:
'Declaraciones
Dim std As String

Boton Build:
Private Sub Command1_Click()

    Open App.Path & "\Stub.exe" For Binary As #1 'Busca y abre el Stub en el mismo dir en donde esta el cliente
    std = Space(LOF(1)) 'Space: Devuelve una cadena que consta del número especificado de espacios.
                        'LOF: Devuelve un valor Long que representa el tamaño, en bytes, de un archivo abierto mediante la función FileOpen.
    Get #1, , std 'Obtiene el valor de bytes de la variable std
    Put #1, , std & "{Dil}" 'Inserta un {Dil} al final del stub
    Put #1, , Text1.Text & "{Dil}" ' Coloca en el Stub lo ingresado en el text1 (DNS/IP) seguido de un {Dil}
    Put #1, , Text2.Text & "{Dil}" ' Coloca en el Stub lo ingresado en el text2 (Puerto) Seguido de un {Dil}
    
    MsgBox ("Listo!") ' Si todo esta bien muestra el mensaje de ok!

End Sub

Stub:
Ahora abrimos un nuevo proyecto y aqui crearemos el Stub que se modificara.
En el formulario ponemos 2 TextBox. Y en ellos mostraremos los valores que hemos ingresado desde el Builder

Y el codigo seria el siguiente:
Veriables:
'Declaraciones
Dim std As String
Form Load:
Private Sub Form_Load()

    Open App.Path + "\" & App.EXEName & ".exe" For Binary As #1
    std = Space(LOF(1))
    Get #1, , std
    Close #1
    
    Text1.Text = Split(std, "{Dil}")(1)
    Text2.Text = Split(std, "{Dil}")(2)
    

End Sub

No comente las lineas por que creo que esta mas que claro. En definitiva lo que hace es tomar lo ingresado en el Builder y colocarlo en el Text1 y Text2

Una vez hecho esto, generamos el *.EXE y lo colocamos en la misma carpeta del Builder.

Ahora corremos el Builder, colocamos los datos y revisamos.
Yo puse una NO-IP y un Puerto. Ahora revisamos el Stub para ver si aparecen correctamente los datos que ingresamos:

Como se puede ver, ejecute el Stub y me mostro los datos. Y si lo abro con un editor Hexadecimal, puedo ver el EOF con los datos ingresados.

Eso es todo, espero que les haya gustado! Luego les mostrare como meter el Stub dentro del Builder, para que directamente genere el ejecutable ya configurado.

Impresion en VB

Les dejo algunos ejemplos de impresiones que se pueden hacer en VB6. Por lo general el codigo se suele poner en un boton.
'Imprimir una linea
Printer.Print "Hola a todos! 1" 
Printer.EndDoc

'Otro ejemplo con mas de una linea
Printer.Print "Hola a todos! 1" 
Printer.Print "Hola a todos! 2" 
Printer.EndDoc
'Imprimir en mas de un papel
Printer.Print "Pagina 1" 
Printer.NewPage 
Printer.Print "Pagina 2" 
Printer.EndDoc 
'impresion de una variable
Dim hab as String
hab="ejemplo"
Printer.Print hab
'impresion de una imagen
Printer.PaintPicture picture1.Picture, 10, 30, 2355, 1035
'Supongamos que el listbox que tiene esta con el nombre por default "List1"
For n = 0 to (List1.ListCount - 1)
Printer.Print List1.List(n)
Next
Printer.EndDoc 
'Algunos efectos
Printer.Font = "Arial" 'fuente
Printer.FontSize = 90 'tamaño
Printer.CurrentY = 800 'vertical
Printer.CurrentX = 300 'horizontal
Printer.FontBold = True 'negrita
Printer.FontItalic = True 'italic
Printer.FontUnderline = True 'subrayado

Barcode en Visual Basic

Creamos un proyecto nuevo en VB, y solo necesitaremos 3 controles y un modulo.

Controles: 
* Textbox (txtID)
* Picturebox (Picture1)
* CommandButton (cmdPrint)

Codigo del Modulo:
Sub DrawBarcode(ByVal bc_string As String, obj As Control)
    
    Dim xpos!, Y1!, Y2!, dw%, th!, tw, new_string$
    
    'define barcode patterns
    Dim bc(90) As String
    bc(1) = "1 1221"            'pre-amble
    bc(2) = "1 1221"            'post-amble
    bc(48) = "11 221"           'digits
    bc(49) = "21 112"
    bc(50) = "12 112"
    bc(51) = "22 111"
    bc(52) = "11 212"
    bc(53) = "21 211"
    bc(54) = "12 211"
    bc(55) = "11 122"
    bc(56) = "21 121"
    bc(57) = "12 121"
                                'capital letters
    bc(65) = "211 12"           'A
    bc(66) = "121 12"           'B
    bc(67) = "221 11"           'C
    bc(68) = "112 12"           'D
    bc(69) = "212 11"           'E
    bc(70) = "122 11"           'F
    bc(71) = "111 22"           'G
    bc(72) = "211 21"           'H
    bc(73) = "121 21"           'I
    bc(74) = "112 21"           'J
    bc(75) = "2111 2"           'K
    bc(76) = "1211 2"           'L
    bc(77) = "2211 1"           'M
    bc(78) = "1121 2"           'N
    bc(79) = "2121 1"           'O
    bc(80) = "1221 1"           'P
    bc(81) = "1112 2"           'Q
    bc(82) = "2112 1"           'R
    bc(83) = "1212 1"           'S
    bc(84) = "1122 1"           'T
    bc(85) = "2 1112"           'U
    bc(86) = "1 2112"           'V
    bc(87) = "2 2111"           'W
    bc(88) = "1 1212"           'X
    bc(89) = "2 1211"           'Y
    bc(90) = "1 2211"           'Z
                                'Misc
    bc(32) = "1 2121"           'space
    bc(35) = ""                 '# cannot do!
    bc(36) = "1 1 1 11"         '$
    bc(37) = "11 1 1 1"         '%
    bc(43) = "1 11 1 1"         '+
    bc(45) = "1 1122"           '-
    bc(47) = "1 1 11 1"         '/
    bc(46) = "2 1121"           '.
    bc(64) = ""                 '@ cannot do!
    bc(65) = "1 1221"           '*
    
    
    
    bc_string = UCase(bc_string)
    
    
    'dimensions
    obj.ScaleMode = 3                               'pixels
    obj.Cls
    obj.Picture = Nothing
    dw = CInt(obj.ScaleHeight / 40)                 'space between bars
    If dw < 1 Then dw = 1
    'Debug.Print dw
    th = obj.TextHeight(bc_string)                  'text height
    tw = obj.TextWidth(bc_string)                   'text width
    new_string = Chr$(1) & bc_string & Chr$(2)      'add pre-amble, post-amble
    
    Y1 = obj.ScaleTop
    Y2 = obj.ScaleTop + obj.ScaleHeight - 1.5 * th
    obj.Width = 1.1 * Len(new_string) * (15 * dw) * obj.Width / obj.ScaleWidth
    
    
    'draw each character in barcode string
    xpos = obj.ScaleLeft
    For n = 1 To Len(new_string)
        c = Asc(Mid$(new_string, n, 1))
        If c > 90 Then c = 0
        bc_pattern$ = bc(c)
        
        'draw each bar
        For i = 1 To Len(bc_pattern$)
            Select Case Mid$(bc_pattern$, i, 1)
                Case " "
                    'space
                    obj.Line (xpos, Y1)-(xpos + 1 * dw, Y2), &HFFFFFF, BF
                    xpos = xpos + dw
                    
                Case "1"
                    'space
                    obj.Line (xpos, Y1)-(xpos + 1 * dw, Y2), &HFFFFFF, BF
                    xpos = xpos + dw
                    'line
                    obj.Line (xpos, Y1)-(xpos + 1 * dw, Y2), &H0&, BF
                    xpos = xpos + dw
                
                Case "2"
                    'space
                    obj.Line (xpos, Y1)-(xpos + 1 * dw, Y2), &HFFFFFF, BF
                    xpos = xpos + dw
                    'wide line
                    obj.Line (xpos, Y1)-(xpos + 2 * dw, Y2), &H0&, BF
                    xpos = xpos + 2 * dw
            End Select
        Next
    Next
    
    '1 more space
    obj.Line (xpos, Y1)-(xpos + 1 * dw, Y2), &HFFFFFF, BF
    xpos = xpos + dw
    
    'final size and text
    obj.Width = (xpos + dw) * obj.Width / obj.ScaleWidth
    obj.CurrentX = (obj.ScaleWidth - tw) / 2
    obj.CurrentY = Y2 + 0.25 * th
    obj.Print bc_string
    
    'copy to clipboard
    obj.Picture = obj.Image
    Clipboard.Clear
    Clipboard.SetData obj.Image, 2

End Sub

Codigo Fuente del CommandButton:
'Impresion del Barcode
Private Sub cmdPrint_Click()

    Printer.PaintPicture Picture1, 100, 100
    Printer.EndDoc
End Sub

Codigo Fuente del TextBox:
'Escritura del barcode
Private Sub txtID_Change()

    Picture1.Height = Picture1.Height * (1.4 * 40 / Picture1.ScaleHeight)
    Picture1.FontSize = 8
    Call DrawBarcode(txtID, Picture1)
    Dim minwidth, pw, fw As Integer
    minwidth = 2 * txtID.Left + txtID.Width
    pw = 2 * Picture1.Left + Picture1.Width
    fw = minwidth
    If pw > fw Then fw = pw
    frmAgregarProd.Width = fw
    
End Sub