PDA

View Full Version : |Lançamento| Códigos Usado No Visual Basic



Biel
06/01/2016, 08:10 PM
Verificar Internet:

MsgBox(My.Computer.Network.IsAvailable)


Verificar se o arquivo existe na pasta:

Em cima de public class coloque esse codigo
Imports System.IO


coloque esse comando em um buton ou aonde voce quizer no form...
IO.File.Exists("c:\teste.txt")


Obter nome entre outras coisas do pc: obs: eu testei a verificaçao de bits do pc e nao está funcional:

MsgBox(My.Computer.Info.OSFullName)
MsgBox(My.Computer.Info.OSPlatform.ToString)
MsgBox(My.Computer.Info.OSVersion.ToString)


Fechar programa:

me.close




Desligar/Logoff/Reiniciar o pc:

'Desliga o Computador
System.Diagnostics.Process.Start("shutdown", "-s -t 00")


'Reinicia o Computador
System.Diagnostics.Process.Start("shutdown", "-r -t 00")


'Faz LogOff no Computador
System.Diagnostics.Process.Start("shutdown", "-l -t 00")


Baixar arquivos para o pc:

My.Computer.Network.DownloadFile("Aqui o link", "Aqui o nome como será baixado")




Abrir outra form:

''form2.show ou form3.show e assim vai, depende do numero da form que voce quer abrir


Abrir pagina na web:

Process.Start("coloque o link aqui")


Mostrar mensagem:

messagebox.show(" Coloque uma mensagem aqui ")


Extrair injetando:

Public Class Form1


Private TargetProcessHandle As Integer
Private pfnStartAddr As Integer
Private pszLibFileRemote As String
Private TargetBufferSize As Integer


Public Const PROCESS_VM_READ = &H10
Public Const TH32CS_SNAPPROCESS = &H2
Public Const MEM_COMMIT = 4096
Public Const PAGE_READWRITE = 4
Public Const PROCESS_CREATE_THREAD = (&H2)
Public Const PROCESS_VM_OPERATION = (&H8)
Public Const PROCESS_VM_WRITE = (&H20)
Dim DLLFileName As String
Public Declare Function ReadProcessMemory Lib "kernel32" ( _
ByVal hProcess As Integer, _
ByVal lpBaseAddress As Integer, _
ByVal lpBuffer As String, _
ByVal nSize As Integer, _
ByRef lpNumberOfBytesWritten As Integer) As Integer


Public Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" ( _
ByVal lpLibFileName As String) As Integer


Public Declare Function VirtualAllocEx Lib "kernel32" ( _
ByVal hProcess As Integer, _
ByVal lpAddress As Integer, _
ByVal dwSize As Integer, _
ByVal flAllocationType As Integer, _
ByVal flProtect As Integer) As Integer


Public Declare Function WriteProcessMemory Lib "kernel32" ( _
ByVal hProcess As Integer, _
ByVal lpBaseAddress As Integer, _
ByVal lpBuffer As String, _
ByVal nSize As Integer, _
ByRef lpNumberOfBytesWritten As Integer) As Integer


Public Declare Function GetProcAddress Lib "kernel32" ( _
ByVal hModule As Integer, ByVal lpProcName As String) As Integer


Private Declare Function GetModuleHandle Lib "Kernel32" Alias "GetModuleHandleA" ( _
ByVal lpModuleName As String) As Integer


Public Declare Function CreateRemoteThread Lib "kernel32" ( _
ByVal hProcess As Integer, _
ByVal lpThreadAttributes As Integer, _
ByVal dwStackSize As Integer, _
ByVal lpStartAddress As Integer, _
ByVal lpParameter As Integer, _
ByVal dwCreationFlags As Integer, _
ByRef lpThreadId As Integer) As Integer


Public Declare Function OpenProcess Lib "kernel32" ( _
ByVal dwDesiredAccess As Integer, _
ByVal bInheritHandle As Integer, _
ByVal dwProcessId As Integer) As Integer


Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Integer


Private Declare Function CloseHandle Lib "kernel32" Alias "CloseHandleA" ( _
ByVal hObject As Integer) As Integer
Dim ExeName As String = IO.Path.GetFileNameWithoutExtension(Application.Ex ecutablePath)


Private Sub Inject()
Dim TargetProcess As Process() = Process.GetProcessesByName("BlackShot")
Dim lpThreadId As IntPtr
Try
TargetProcessHandle = OpenProcess(&H1F0FFF, 0, TargetProcess(0).Id)
pszLibFileRemote = ("C:\Windows\System32\nomedasuadll.dll")
pfnStartAddr = GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA")
TargetBufferSize = 1 + Len(pszLibFileRemote)
Dim Rtn As Integer
Dim LoadLibParamAdr As Integer
LoadLibParamAdr = VirtualAllocEx(TargetProcessHandle, 0, TargetBufferSize, MEM_COMMIT, PAGE_READWRITE)
Rtn = WriteProcessMemory(TargetProcessHandle, LoadLibParamAdr, pszLibFileRemote, TargetBufferSize, 0)
CreateRemoteThread(TargetProcessHandle, 0, 0, pfnStartAddr, LoadLibParamAdr, 0, lpThreadId)
If lpThreadId = IntPtr.Zero Then
Else
End If
Catch ex As Exception
End Try
End Sub


'####################
'Extrair e verificar
'####################
IO.File.WriteAllBytes("C:\Windows\System32\nomedas uadll.dll", My.Resources.nomedasuadllnoresources) 'extrair dll no System32
If IO.File.Exists("C:\Windows\System32\nomedasuadll.d ll") Then 'verificar se a dll está no system32 se não estiver
Timer4.Start()


Else
IO.File.WriteAllBytes("C:\Windows\System32\nomedas uadll.dll", My.Resources.nomedasuadllnoresources) ' se a dll não estiver no system32,a dll em resources, vai ser extraida.


End If


'####################
'Extrair e verificar
'####################
Dim TargetProcess As Process() = Process.GetProcessesByName("BlackShot") 'verificar se o processo está aberto
If TargetProcess.Length = 0 Then
Me.Label9.Text = ("Esperando por BlackShot ...") 'se não estiver.


Else
Call Inject() 'injetarDLL 'Inject = Private Sub Inject()
End If


Colocando musica:

My.Computer.Audio.Play(My.Resources.Coloque a musica aqui,
AudioPlayMode.BackgroundLoop)


Deletar arquivo da pasta:

IO.File.Delete("LocalDaDllPC")


Mesagem "Deseja realmente fechar o form?" :

If MsgBox("Deseja fechar?", MsgBoxStyle.OkCancel) = MsgBoxResult.Ok Then
Me.Close()
else
end if


Finalizar processos:

Dim processo As Process() = Process.GetProcessesByName("Nome Do Processo")
For Each p In processo
p.Kill()
Next




Verificar se foi aberto como adm:

If My.User.IsInRole(ApplicationServices.BuiltInRole.A dministrator) Then
MsgBox("O Programa foi aberto como administrador!!!")
Else
MsgBox("O Programa deve ser aberto como Administrador!! o programa sera fechado!")
Me.Close()
End If


Crypter para vb:

Imports System.IO
Imports System.Text
Imports System.Security.Cryptography


Public Class Crypto


Public Shared Function Decrypt(ByVal input As String, ByVal pass As String) As String
Dim AES As New System.Security.Cryptography.RijndaelManaged
Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvi der
Dim decrypted As String = ""
Try
Dim hash(31) As Byte
Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASC II.GetBytes(pass))
Array.Copy(temp, 0, hash, 0, 16)
Array.Copy(temp, 0, hash, 15, 16)
AES.Key = hash
AES.Mode = Security.Cryptography.CipherMode.ECB
Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateDecryptor
Dim Buffer As Byte() = Convert.FromBase64String(input)
decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecry pter.TransformFinalBlock(Buffer, 0, Buffer.Length))
Return decrypted
Catch ex As Exception
End Try
End Function


End Class


Protection vb:
#Region "Process Protection"
Public Const SE_DEBUG_NAME As String = "SeDebugPrivilege"
Public Const SE_SHUTDOWN_NAME As String = "SeShutdownPrivilege"
Public Const SE_SECURITY_NAME As String = "SeSecurityPrivileges"
Public Const SE_TCB_NAME As String = "SeTcbPrivileges"
Public Const SE_TAKE_OWNERSHIP_NAME As String = "SeTakeOwnershipPrivileges"


Private Structure LUID
Public LowPart As Integer
Public HighPart As Integer
End Structure


Private Structure LUID_AND_ATTRIBUTES
Public pLuid As LUID
Public Attributes As Integer
End Structure


Private Structure TOKEN_PRIVILEGES
Public PrivilegeCount As Integer
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=ANYSIZE_ARRAY)> _
Public Privileges() As LUID_AND_ATTRIBUTES
End Structure


Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Ansi Function OpenProcessToken Lib "advapi32.dll" (ByVal ProcessHandle As IntPtr, ByVal DesiredAccess As Integer, ByRef TokenHandle As IntPtr) As Integer
Private Declare Ansi Function LookupPrivilegeValue Lib "advapi32.dll" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, ByRef lpLuid As LUID) As Integer
Private Declare Ansi Function AdjustTokenPrivileges Lib "advapi32.dll" (ByVal TokenHandle As IntPtr, ByVal DisableAllPrivileges As Boolean, ByRef NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Integer, ByRef PreviousState As TOKEN_PRIVILEGES, ByRef ReturnLength As IntPtr) As Integer
Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hHandle As IntPtr) As Boolean
Public Declare Sub RtlSetProcessIsCritical Lib "ntdll.dll" (ByVal NewValue As Boolean, ByVal OldValue As Boolean, ByVal WinLogon As Boolean)


Private Const TOKEN_ADJUST_PRIVILEGES As Integer = &H20
Private Const TOKEN_QUERY As Integer = &H8
Private Const SE_PRIVILEGE_ENABLED As Integer = &H2
Private Const ANYSIZE_ARRAY As Integer = 1


Public Function GetPrivileges(ByVal privileges As String) As Boolean
Dim hToken As IntPtr
Dim hProcess As IntPtr = Process.GetCurrentProcess().Handle
Dim uid_Debug As LUID
Dim luaAttr As New LUID_AND_ATTRIBUTES
Dim newState As New TOKEN_PRIVILEGES
Dim prevState As TOKEN_PRIVILEGES = New TOKEN_PRIVILEGES
Dim returnLength As IntPtr


Try
If LookupPrivilegeValue("", privileges, uid_Debug) = 0 Then Return False
If OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY, hToken) = 0 Then Return False
luaAttr.pLuid = uid_Debug
luaAttr.Attributes = SE_PRIVILEGE_ENABLED
newState.PrivilegeCount = 1
newState.Privileges = New LUID_AND_ATTRIBUTES() {luaAttr}
ReDim prevState.Privileges(CInt(newState.PrivilegeCount) )
If AdjustTokenPrivileges(hToken, False, newState, Marshal.SizeOf(prevState), prevState, returnLength) = 0 Then Return False
Finally
CloseHandle(hToken)
End Try
Return True
End Function
#End Region






Coloque isso no FormLoad:
Código:
GetPrivileges(SE_SECURITY_NAME)
RtlSetProcessIsCritical(True, False, False)


Gerar Cor :

Dim random As New Random
Label1.ForeColor = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255), random.Next(0, 255))


Alterar Cor :

Exemplo: .ForeColor = Color.Cor


Facebook Ant Lech :

[Only registered and activated users can see links] quipetgh&width=235&height=258&colorscheme=light&show_faces=true&header=false&stream=false&show_border=true




Mensagens :

msgbox("Texto ")
MsgBox("Texto", MsgBoxStyle.Exclamation, "Texto ")
MsgBox("Seja Bem Vindo(A) " & TextBox1.Text, vbInformation)
MsgBox("Login ou senha incorretos", vbExclamation)


Abrir Link Navegador :

System.Diagnostics.Process.Start("Site")
Process.Start("Link")


Retirando UC :

On Error Resume Next




Lembrando TextBox :

On Error Resume Next
TextBox1.Text = My.Settings.usuario
TextBox2.Text = My.Settings.senha
CheckBox1.Checked = My.Settings.check
CheckBox2.Checked = My.Settings.check2
If CheckBox1.Checked = False Then
Timer1.Stop()
TextBox1.Clear()
TextBox2.Clear()
Else
Timer1.Start()
End If
CheckBox
If CheckBox1.Checked = True Then
My.Settings.check = True
Timer1.Start()
Else
My.Settings.check = False
Timer1.Stop()
End If


Timer


My.Settings.usuario = TextBox1.Text
My.Settings.senha = TextBox2.Text
My.Settings.Save()
My.Settings.check = CheckBox1.Checked




Mostrar Senha :

CheckBox


If CheckBox2.Checked Then
TextBox2.PasswordChar = ""
Else
TextBox2.PasswordChar = "*"
End If
My.Settings.check2 = CheckBox2.Checked
End Sub




Mandar para systemtray :

NotifcyIco
ContextMenuStrip
Me.Show()
Button
Me.Hide()
NotifyIcon1.BalloonTipTitle = "Hey"
NotifyIcon1.BalloonTipText = "Eu estou aqui ainda em!" & vbNewLine & _
"Mas nesse cantinho ^^" & vbNewLine & "Não vá se esquecer de min !"
NotifyIcon1.ShowBalloonTip(500)
NotifyIcon1.Visible = True




Login Fórum :

Imports System.Net
Imports System.IO
Imports System.Text
Imports System.Security.Cryptography
Dim data As String
Public Function Login(ByVal Username As String, ByVal Password As String)
data = "vb_login_username=" & Username & "&vb_login_password=&s=&do=login&vb_login_md5password=" & Password & "&vb_login_md5password_utf=" & MD5(Password)
Try
Dim request As [Only registered and activated users can see links] = WebRequest.Create("link forum")
request.Method = WebRequestMethods.[Only registered and activated users can see links]
request.ContentType = "application/x-[Only registered and activated users can see links]"
request.ContentLength = data.Length
Dim rStream As New StreamWriter(request.GetRequestStream)
rStream.Write(data)
rStream.Flush()
rStream.Close()
Dim response As [Only registered and activated users can see links] = request.GetResponse
Dim resReader As New StreamReader(response.GetResponseStream)
Dim str As String = resReader.ReadToEnd
If str.Contains("Bem-vindo(a),") Then
Return True
Else
Return False
End If
response.Close()
Catch ex As Exception
Return False
End Try
End Function
Friend Function MD5(ByVal number As String) As String
Dim ASCIIenc As New ASCIIEncoding
Dim strReturn As String = String.Empty
Dim ByteSourceText() As Byte = ASCIIenc.GetBytes(number)
Dim Md5Hash As New MD5CryptoServiceProvider
Dim ByteHash() As Byte = Md5Hash.ComputeHash(ByteSourceText)
For Each b As Byte In ByteHash
strReturn &= b.ToString("x2")
Next
Return strReturn
End Function
End Module


----------------------------------------------------------------------------------------
Button :
If Login(TextBox1.Text, TextBox2.Text) = True Then
Form2.Show()
Me.Hide()


Else
MsgBox("Login ou Senha Incorretos, Tente Novamente!", MsgBoxStyle.Exclamation, "Erro")


End If


Gerar Caption / Titulo Form :

Dim Letters As New List(Of Integer)
For i As Integer = 48 To 57 'ASCII Code
Letters.Add(i)
Next
For i As Integer = 97 To 122 'Lower Case
Letters.Add(i)
Next
For i As Integer = 65 To 90 'Upper Case
Letters.Add(i)
Next
For i As Integer = 33 To 42 'Special Chars
Letters.Add(i)
Next
Dim rnd As New Random
Dim SB As New System.Text.StringBuilder
Dim Temp As Integer
For count As Integer = 1 To 15 'Amount
Temp = rnd.Next(0, Letters.Count)
SB.Append(Chr(Letters(Temp)))
Next
Me.Text = SB.ToString


[Only registered and activated users can see links]
Dim r As New Random


For i As Integer = 1 To 18
Dim idx As Integer = r.Next(0, 35)
sb.Append(str.Substring(idx, 1))
Next
Me.Text = sb.ToString




Ativar Por Teclas :

Private Declare Function GetKeyPress Lib "user32" Alias "GetAsyncKeyState" (ByVal key As Integer) As Integer


Em um Timer Coloque : True / Interval = 1]


If GetKeyPress(Keys.ControlKey) Then
Timer1.Start
Else
Timer1.Stop
End If




VB.NET Sistema de Login – Simples :

If TextBox1.Text = "login123" And TextBox2.Text = "senha123" Then
Me.Hide()
Form2.Show()
'Se o Login e Senha for correspondente ao TextBox1 e TextBox2, Ira Abrir o Form2.
Else
MessageBox.Show("Login ou Senha estão Incorretos!")
'Se o login e Senha estiverem errados, Ira exibir uma caixa de mensagem.
End If




[VB.NET] Contar tique-taque do Timer :

Dim contagem As Integer = 0
contagem = contagem + 1
Label1.Text = contagem


Att: Biel
Estou deixando esses codicos Aqui para quem Intende De Visual Basic.
Player : Mais Biel e quem Nao Itende ?
Biel : Em Breve estarei dando tutorias Para Ensinar voces .