Powershell script to stop pc sleeping
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
# Get initial mouse position
$lastPosition = [System.Windows.Forms.Cursor]::Position
# Set the maximum pixel offset for left/right movement
$offset = 2 # You can change this value to 1 or 2 based on your preference
while ($true) {
# Get the current mouse position
$currentPosition = [System.Windows.Forms.Cursor]::Position
# Check if the mouse has moved
if ($currentPosition -ne $lastPosition) {
# Randomly move the mouse slightly to the left or right
$moveDirection = Get-Random -Minimum -1 -Maximum 2 # -1 (left) or 1 (right)
$newX = $currentPosition.X + $moveDirection * $offset
# Ensure the new position is within screen bounds
$screenWidth = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width
if ($newX -lt 0) { $newX = 0 }
if ($newX -gt $screenWidth) { $newX = $screenWidth }
# Update the mouse position
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($newX, $currentPosition.Y)
# Update last known position
$lastPosition = [System.Windows.Forms.Cursor]::Position
}
# Sleep for a small amount before checking again (optional, you can adjust this)
Start-Sleep -Milliseconds 200
}
I wanted to setup some programs to run as Windows Services but found information on the subject to be scattered around everywhere. So this post is basically for consolidation and clarification but is not focused on unattended installations.
What is a Service?
A Windows Service is automatically started when your system boots. There is no need to logon to the system. Services also are not affected by people logging off. Services automatically recover from program crashes and Standby and Hibernation modes. Windows 9x/ME do not have a Service facility. Installing software as a Service requires Administrator permissions.
What are the options for running a program as a Service?
sc.exe
This is Microsoft software and is installed by default on XP and 2003. It is probably the best and easiest method but it won't work if the target executable was not programmed to run as a Service. This rules it out for what many people are trying to do since most programs that are designed ro run as a Service have that option included somewhere in the application. sc.exe is useful for the Unattended crowd, though.
The syntax for sc.exe is worth noting. This will NOT work:
Quote
sc create YourServiceName binPath="c:\Program Files\directory\appname.exe"
But this WILL work (note the space after the =):
Quote
sc create YourServiceName binPath= "c:\Program Files\directory\appname.exe"
Two other useful options, with the same syntax as above, are:
type= <own|share|interact|kernel|filesys|rec>
(default = own)
start= <boot|system|auto|demand|disabled>
(default = demand)
You can use these commands for more details:
sc /?
sc create /?
instsrv.exe and srvany.exe
This is Microsoft software but was published as part of the Resource Kits. You can download the files here or here. Thanks to tacktech.com for providing the fileset.
Instrsrv.exe installs the Service but srvany.exe is the real gem here as it is a wrapper that allows any software to be run as a Service. This method worked great for me but does require manual registry edits.
Here is a quick summary of the steps invloved but you can find more complete instructions at Microsoft's KB page or TackTech's page with great screenshots.
Unpack the fileset to a folder of your choice. srvany.exe needs to remain on your system for this method to work, so put it somewhere like Program files where you won't mind leaving it around. I use C:\Program Files\services in this example.
Install the Service with a command like this:
C:\Program Files\services\Instsrv.exe YourServiceName C:\Program Files\services\Srvany.exe
Using a registry editor, find this key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\YourServiceName
Add a new sub-key called Parameters.
In the Parameters key, create a new string value named Application.
Set the value data of Application to the full path of the executable file that you want the service to launch. For example, C:\WINNT\notepad.exe.
Using the Services console, find your new service and make any necessary property edits. This dialog will allow you to set the startup type, logon method, and program failure options.
One problem I ran into with this method was task tray entries. Some programs won't work if their task tray entry fails. If the software you want to run wants to put an icon in the task tray you can try enabling "Allow service to interact with the desktop" on the "Log On" tab of the Service properties. If that doesn't work you could also try disabling the task tray entry for the program.
Launcher Service
Camarade_Tux recommends Launcher Service. It is free and open source and looks very flexible and useful. This program has several unique features:
Start or stop a program based on network connectivity
External program can be run before or after execution
Delete *.tmp and *.pid files from the program's startup folder before execution
WinServ
Quote
WinServ is a utility that can create an NT service that runs any application. When the application exits, the service becomes stopped.
I did not try this program but included it here since it is free, open source and looks useful.
Non-free options
There are quite a few shareware and payware options. I didn't try any of them but I hear that FireDaemon works well for a lot of people.
VBS option
CreateService.vbs
Const OWN_PROCESS = 16
Const NOT_INTERACTIVE = False
Const NORMAL_ERROR_CONTROL = 2
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & _
"{impersonationLevel=Impersonate}!\\" & strComputer & "\root\cimv2")
Set objService = objWMIService.Get("Win32_BaseService")
errReturn = objService.Create("DbService", _
"NAME", _
"C:\WINDOWS\PROGRAM.EXE", _
OWN_PROCESS, _
NORMAL_ERROR_CONTROL, _
"Manual", _
NOT_INTERACTIVE, _
"NT AUTHORITY\LocalService", "")
RemoveService.vbs
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where Name = 'SERVICE_NAME'")
For Each objService in colListOfServices
objService.StopService()
objService.Delete()
Next
Finding the RID Master, PDC Emulator, and Infrastructure Masters via GUI
To find out who currently holds the Domain-Specific RID Master, PDC Emulator, and Infrastructure Master FSMO Roles:
Open the Active Directory Users and Computers snap-in from the Administrative Tools folder.
Right-click the Active Directory Users and Computers icon again and press Operation Masters. Finding the Domain Naming Master via GUI
To find out who currently holds the Domain Naming Master Role:
1. Open the Active Directory Domains and Trusts snap-in from the Administrative Tools folder.
2. Right-click the Active Directory Domains and Trusts icon again and press Operation Masters. 10 Finding the Schema Master via GUI
To find out who currently holds the Schema Master Role:
Register the Schmmgmt.dll library by pressing Start & RUN and typing:
regsvr32 schmmgmt.dll
1. Press OK. You should receive a success confirmation.
2. From the Run command open an MMC Console by typing MMC.
3. On the Console menu, press Add/Remove Snap-in.
4. Press Add. Select Active Directory Schema.
5. Press Add and press Close. Press OK.
6. Click the Active Directory Schema icon. After it loads right-click it and press Operation Masters. The FSMO role holders can be easily found by use of the Ntdsutil command.
Caution: Using the Ntdsutil utility incorrectly may result in partial or complete loss of Active Directory functionality.
On any domain controller, click Start, click Run, type Ntdsutil in the Open box, and then cl19 ick OK.
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.
C:WINDOWS\ntdsutil
ntdsutil:
1. Type roles, and then press ENTER.
ntdsutil: roles
fsmo maintenance:
Note: To see a list of available commands at any of the prompts in the Ntdsutil tool, type ?, and then press ENTER.
1. Type connections, and then press ENTER.
fsmo maintenance: connections
server connections:
1. Type connect to server ;servername;, where ;servername> is the name of the server you want to use, and then press ENTER.
server connections: connect to server server100
Binding to server100...
Connected to server using credentials of locally logged on user.
server connections:
1. At the server connections: prompt, type q, and then press ENTER again.
server connections: q
fsmo maintenance:
1. At the FSMO maintenance: prompt, type Select operation target, and then press ENTER again.
fsmo maintenance: Select operation target
select operation target:
1. At the select operation target: prompt, type List roles for connected server, and then press ENTER again.
select operation target: List roles for connected server
Server "server100" knows about 5 roles
Schema - CN=NTDS Settings,CN=SERVER100,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=C
onfiguration,DC=dpetri,DC=net
Domain - CN=NTDS Settings,CN=SERVER100,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=C
onfiguration,DC=dpetri,DC=net
PDC CN=NTDS Settings,CN=SERVER100,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Conf
iguration,DC=petri,DC=net
RID - CN=NTDS Settings,CN=SERVER100,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=dpetri,DC=net
Infrastructure - CN=NTDS Settings,CN=SERVER100,CN=Servers,CN=Defau37 lt-First-Site-Name,CN=Sites,CN=Configuration,DC=dpetri,DC=net
select operation target:
1. Type q 3 times to exit the Ntdsutil prompt.
Note: You can download THIS nice batch file that will do all this for you (1kb).
Another Note: Microsoft has a nice tool called Dumpfsmos.cmd, found in the Windows 2000 Resource Kit (and can be downloaded here: Download Free Windows 2000 Resource Kit Tools). This tool is basically a one-click Ntdsutil sc<x>ript that performs the same operation described above. The FSMO role holders can be easily found by use of the Netdom command.
Netdom.exe is a part of the Windows 2000/XP/2003 Support Tools. You must either download it separately (from here Download Free Windows 2000 Resource Kit Tools) or by obtaining the correct Support Tools pack for your operating 46 system. The Support Tools pack can be found in the SupportTools folder on your installation CD (or you can Download Windows 2000 SP4 Support Tools, Download Windows XP SP1 Deploy Tools).
1. On any domain controller, click Start, click Run, type CMD in the Open box, and then click OK.
2. In the Command Prompt window, type netdom query /domain:<domain> fsmo (where <domain> is the name of YOUR domain).
C:WINDOWS>netdom query /domain:yourdomain fsmo
Schema owner server1.yourdomain.net
Domain role owner server1.yourdomain.net
PDC role server1.yourdomain.net
RID pool manager server1.yourdomain.net
Infrastructure owner server1.yourdomain.net
The command completed success-1 fully. I would Suggest running this from cmd using : csc<x>ript c:listall.vbs
here is the listall.vbs
------------------------
'put your domains in below
domains = Array("int", "sussex")
For56 Each domain In domains
Wsc<x>ript.Echo "*********** Querying: " & domain & " *************"
getdomaininfo domain
Wsc<x>ript.echo
Next
Sub getdomaininfo(domain)
'needed for the gc queries
On Error Resume Next
Set objRootDSE = Getob<x>ject("LDAP://" & domain & "/rootDSE")
'ugly code follows...
Set objSchema = Getob<x>ject _
("LDAP://" & objRootDSE.Get("schemaNamingContext"))
strSchemaMaster = objSchema.Get("fSMORoleOwner")
Set objNtds = Getob<x>ject("LDAP://" & strSchemaMaster)
Set objComputer = Getob<x>ject(objNtds.Parent)
Wsc<x>ript.Echo "Forest-wide Schema Master FSMO: " & objComputer.Name
Set objNtds = Nothing
Set objComputer = Nothing
Set objPartitions = Getobject("LDAP://CN=Partitions," & _
objRootDSE.Get("configurationNamingContext"))
strDomainNamingMaster = objPartitions.Get("fSMORoleOwner")
Set objNtds = Getobject("LDAP://" & strDomainNamingMaster)
Set objComputer = Getobject(objNtds.Parent)
67
Wscript.Echo "Forest-wide Domain Naming Master FSMO: " & objComputer.Name
Se68 t objDomain = Getobject _
("LDAP://" & objRootDSE.Get("defaultNamingContext"))
69 strPdcEmulator = objDomain.Get("fSMORoleOwner")
Set objNtds = Getob<x>ject("LDAP://" & strPdcEmulator)
Set objComputer = Getobject(objNtds.Parent)
Wscript.Echo "Domain's PDC Emulator FSMO: " & objComputer.Name
Set objRidManager = Getobject("LDAP://CN=RID Manager$,CN=System," & _
objRootDSE.Get("defaultNamingContext"))
strRidMaster73 = objRidManager.Get("fSMORoleOwner")
Set objNtds = Getobject("LDAP://" & strRidMaster)
Set objComputer = Getobject(objNtds.Parent)
Wscript.Echo "Domain's RID Master FSMO: " & objComputer.Name
Set objInfrastructure = Getob<x>ject("LDAP://CN=Infrastructure," & _
objRootDSE.Get("defaultNamingContext"))
strInfrastructureMaster = objInfrastructure.Get("fSMORoleOwner")
Set objNtds = Getobject("LDAP://" & strInfrastructureMaster)
Set objComputer = Getobject(objNtds.Parent)
Wscript.Echo "Domain's Infrastructure Master FSMO: " & objComputer.Name
'check for global catalogs
Const NTD80 SDSA_OPT_IS_GC = 1
Set objGC = Getobject("LDAP://OU=Domain Controllers," & _
ob81 jRootDSE.Get("defaultNamingContext"))
For Each gc In objGC
'clean up the ldap response
82 gc = Replace(gc.name, "CN=", "")
Set objRootDSE = Getobject("LDAP://" & gc &83 "/rootDSE")
strDsServiceDN = objRootDSE.Get("dsServiceName")
Set objDsRoot = Getobject("LDAP://" & gc & "/" & strDsServiceDN)
'this doesnt always exist therefore we 85 have to use on error resume next
intOptions = objDsRoot.Get("options")
'check to see if the previous command failed with the err.number function
If intOptions And NTDSDSA_OPT_I87 S_GC and err.Number = 0 Then
Wscript.Echo gc & " is a global catalog server."
88 Else
Wscript.Echo gc & " isnt up or isnt a global catalog server."
89 Err.Clear
End If
next
End Sub 'getdomaininfo
----------------------------------------------
netsh dhcp server \[servername] show scope |qgrep [dhcpscope name]
handy commend to save trolling through all the dhcp scopes to find the site in question
vbs to force device to renew ip address
####################
'LogFile = "results.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
'Set objTextFile = fso.OpenTextFile(LogFile, 2, True)
On Error resume next
strComputer = inputbox ("Enter the PC Hostname that you want to renew the ip address for :")'f.ReadLine
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
If Err.Number <> 0 Then
objTextFile.WriteLine(intCount & ". " & strComputer & " is not responding.")
Err.Clear
Else
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.RenewDHCPLeaseAll()
End If
'Loop
#########################
#################### write file ########################
Dim sFileText As String
Dim iFileNo As Integer
iFileNo = FreeFile
'open the file for writing
Open "c:bradf_tj.time" For Output As #iFileNo
'please note, if this file already exists it will be overwritten!
'write some example text to the file
Print #iFileNo, "Project Timer 1"
Print #iFileNo, Text1.Text
Print #iFileNo, mintCountmin1
Print #iFileNo, mintCount1
Print #iFileNo, "Project Timer 2"
Print #iFileNo, Text2.Text
Print #iFileNo, mintCountmin2
Print #iFileNo, mintCount2
Print #iFileNo, "Project Timer 3"
Print #iFileNo, Text3.Text
Print #iFileNo, mintCountmin3
Print #iFileNo, mintCount3
Print #iFileNo, "Project Timer 4"
Print #iFileNo, Text4.Text
Print #iFileNo, mintCountmin4
Print #iFileNo, mintCount4
Print #iFileNo, "Project Timer 5"
Print #iFileNo, Text5.Text
Print #iFileNo, mintCountmin5
Print #iFileNo, mintCount5
'close the file (if you dont do this, you wont be able to open it again!)
Close #iFileNo
##################################
################# read file ###############
Dim S As String
Dim strfile, strLines1, strlines2, strlines3, strlines4, strlines5, strlines6, strlines7
strfile = Command
If strfile = "" Then
MsgBox "no input file found" & vbCr & "Command Example: " & vbCr & "c:autossh.exe c:sshsettings.txt"
Else
End If
Open strfile For Input As 2
On Error Resume Next
Line Input #2, strLines1
Line Input #2, strlines2
Line Input #2, strlines3
Line Input #2, strlines4
Line Input #2, strlines5
Line Input #2, strlines6
Line Input #2, strlines7
Close #2
another example
Open "C:bradf_tj.time" For Input As #2
'change this filename to an existing file! (or run the example below first)
'read the file until we reach the end
On Error Resume Next
Line Input #2, strlinesdes1
Line Input #2, strLines1
Line Input #2, strlines2
Line Input #2, strlines3
Line Input #2, strlinesdes2
Line Input #2, strlines4
Line Input #2, strlines5
Line Input #2, strlines6
Line Input #2, strlinesdes3
Line Input #2, strLines7
Line Input #2, strlines8
Line Input #2, strlines9
Line Input #2, strlinesdes4
Line Input #2, strlines10
Line Input #2, strlines11
Line Input #2, strlines12
Line Input #2, strlinesdes5
Line Input #2, strLines13
Line Input #2, strlines14
Line Input #2, strlines15
Close #2
########################################
.exe from zip - the file -
here : https://drive.google.com/file/d/1vXbSg8UbQSXWimCvvJRnPK-Kt7FQBMST/view?usp=sharing
Setting up Your Compiler
Once you've downloaded the Borland compiler, you can take take the default installation options, including the default directory, "c:BorlandBCC55". Once you've done that, follow the instructions below to get the compiler ready to use.
First, we need to tell the compiler where to find the include files and supporting libraries. To do this, open up notepad (or any other text editor) and paste the following two lines into a blank file:
-I"c:BorlandBcc55include"
-L"c:BorlandBcc55lib"
Save this file in notepad as "c:borlandbcc55binbcc32.cfg". To do this, just go to "Save As" under the "File" menu, then type the entire file name, in quotes, into notepad. You need to include the quotes to keep it from adding a .txt extension.
Now paste the following line into a new blank text file:
-L"c:BorlandBcc55lib"
Save this new file as "c:borlandbcc55binili<x>nk32.cfg"
Great, now you're ready to start writing and compiling programs
http://catchvideo.net/
$user = "tjba"
$pword = ConvertTo-SecureString -String "abc123" -Asplaintext -Force
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
#thats the tricky bit done - now just fire off your command with the credentials variable.
below will add a user to a group :
Add-ADGroupMember -Identity "general-group-name" -members "jbloggs" -Server "ad.susx.abc.123" -Credential $Credential
two parts to this code - the code
#start of code titled this2.vbs
Dim hosts(4)
hosts(0) = "8.8.8.8"
hosts(1) = "8.8.4.4"
hosts(2) = "192.168.1.1"
hosts(3) = "10.0.0.1"
hosts(4) = "google.com"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
Do
'Create status file
Set objFile = objFSO.CreateTextFile("status.hta", True)
'Write HTA header and meta tags
objFile.WriteLine "<!DOCTYPE html>"
objFile.WriteLine "<html>"
objFile.WriteLine "<head>"
objFile.WriteLine "<meta charset='UTF-8'>"
objFile.WriteLine "<meta http-equiv='X-UA-Compatible' content='IE=edge'>"
objFile.WriteLine "<meta http-equiv='refresh' content='60'>"
objFile.WriteLine "<title>Status</title>"
objFile.WriteLine "</head>"
objFile.WriteLine "<body>"
'Write timestamp
objFile.WriteLine "<p>" & Now & "</p>"
'Check status of each host
For i = 0 To UBound(hosts)
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
("select * from Win32_PingStatus where address='" & hosts(i) & "'")
For Each objStatus in objPing
If objStatus.StatusCode = 0 Then
'Host is up
objFile.WriteLine "<p>" & hosts(i) & " is up! Response time: " & objStatus.ResponseTime & "ms</p>"
Else
'Host is down
objFile.WriteLine "<p>" & hosts(i) & " is down!</p>"
End If
Next
Next
# end of this2.vbs
then the .hta file called status.hta (this is built dynamically)
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<meta http-equiv='refresh' content='60'>
<title>Status</title>
</head>
<body>
<p>18/04/2023 12:07:38</p>
<p>8.8.8.8 is up! Response time: 6ms</p>
<p>8.8.4.4 is up! Response time: 7ms</p>
<p>192.168.1.1 is down!</p>
<p>10.0.0.1 is down!</p>
<p>google.com is up! Response time: 7ms</p>
#################
Dim hosts(4)
hosts(0) = "8.8.8.8"
hosts(1) = "8.8.4.4"
hosts(2) = "192.168.1.1"
hosts(3) = "10.0.0.1"
hosts(4) = "google.com"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
Do
'Create status file
Set objFile = objFSO.CreateTextFile("status.hta", True)
'Write HTA header and meta tags
objFile.WriteLine "<!DOCTYPE html>"
objFile.WriteLine "<html>"
objFile.WriteLine "<head>"
objFile.WriteLine "<meta charset='UTF-8'>"
objFile.WriteLine "<meta http-equiv='X-UA-Compatible' content='IE=edge'>"
objFile.WriteLine "<meta http-equiv='refresh' content='60'>"
objFile.WriteLine "<title>Status</title>"
objFile.WriteLine "</head>"
objFile.WriteLine "<body>"
'Write timestamp
objFile.WriteLine "<p>" & Now & "</p>"
'Check status of each host
For i = 0 To UBound(hosts)
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
("select * from Win32_PingStatus where address='" & hosts(i) & "'")
For Each objStatus in objPing
If objStatus.StatusCode = 0 Then
'Host is up
objFile.WriteLine "<p>" & hosts(i) & " is up! Response time: " & objStatus.ResponseTime & "ms</p>"
Else
'Host is down
objFile.WriteLine "<p>" & hosts(i) & " is down!</p>"
End If
Next
Next
'Close the file and loop after 60 seconds
objFile.Close
WScript.Sleep(60000)
Loop
####################
runas /netonly /user:u**s\t***9da "mmc /server=***.***.15.12"
some weirdness exists when trying to apply changes - password prompting etc but it can be cancelled.
support tool is here : https://www.microsoft.com/en-gb/download/details.aspx?id=45520
then add
apps and features
optional features
add a feature
rsat - active directory domain servers ldap
power shell version :
open powershell as admin
Get-WindowsCapability -Name RSAT* -Online | Add-WindowsCapability -Online
Add-ADGroupMember -Identity "general-chn-vp" -members "256" -Server "ad..**.uk" -Credential tj**a
%date:~7,2%-%date:~4,2%-%date:~10,4%
Echo Backup Certification Authority, Certificates, Templates and CSP
c:
cd scripts
rem dat example day month year mkdir %date:~3,2%-%date:~0,2%-%date:~6,4%
rem Echo Y| del C:ca-backupdataba<x>se
rem rd C:ca-backupdatabase
rem Echo Y| del c:ca-backup
Echo Backing up the Certification Authority and Certificates
certutil -backup -p backup c:ca-backup%date:~3,2%-%date:~0,2%-%date:~6,4%
Echo Backing up the registry keys
reg export HKLMSystemCurrentControlSetServicesCertSvcConfiguration
c:ca-backup%date:~3,2%-%date:~0,2%-%date:~6,4%regkey.reg
Certutil –getreg CACSP > C:ca-backup%date:~3,2%-%date:~0,2%-%date:~6,4%CSP.txt
Echo Documenting all certificate templates published at the CA
Certutil –catemplates > C:ca-backup%date:~3,2%-%date:~0,2%-%date:~6,4%CATemplates.txt
above is a script i use to backup CA certificates both user and root
you will need to save this to your c:\ drive as putty.bat
**********************************
set var=%1
set extract=%var:~6,-1%
rem msg %username% "12345" %extract%
rem "C:\Program Files\PuTTY\putty.exe" %extract%
rem "C:\Windows\System32\bash.exe" ~/grabber.sh %extract%
ECHO OFF
CLS
:MENU
ECHO.
ECHO ...............................................
ECHO PRESS 1, 2 OR 3 to select your task, or 4 to EXIT.
ECHO ...............................................
ECHO.
ECHO 1 - Open Putty
ECHO 2 - Open Nix
ECHO 3 - EXIT
ECHO.
SET /P M=Type 1, 2, 3, or 4 then press ENTER:
IF %M%==1 GOTO PUTTY
IF %M%==2 GOTO NIX
IF %M%==3 GOTO EXIT
:PUTTY
"C:\Program Files\PuTTY\putty.exe" %extract%
GOTO MENU
:NIX
"C:\Windows\System32\bash.exe" ~/grabber.sh %extract%
GOTO MENU
:EXIT
exit
********************************************************
You will need to add this to the registry
********************************************************
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\ssh]
@="URL:ssh Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\ssh\shell]
[HKEY_CLASSES_ROOT\ssh\shell\open]
[HKEY_CLASSES_ROOT\ssh\shell\open\command]
@="\"C:\\putty.bat\" %1"
**********************************************************
reboot the pc and away you go.
this in the browser will make you click and login friendly - ssh://tjb39@hp-e-shaw-1-112-sw6-poe.net.susx.ac.uk
*****************************
if you are running linux you will want this file (grabber.sh )
expect ~/formal-example.sh $1
read -p "123"
*********************************
and then expect formal-example.sh
***********************************
# this example will connect to a device run a command then exit
# you can output the result to a file > caputre.txt to then use.
#!/usr/bin/expect
set input [lindex $argv 0];
match_max 100000
spawn ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 $input
send "y\r"
expect "assword:"
send "Dekatron51!\r"
expect -re "\[#\$%]"
send "show ip\r"
interact
~
**********************************************
* NETCAT *
simple chat app
nc (dest ip) -v (port number) (client end)
nc -lvp (port) (server end)
this will provide a simple cmd chat application.
gain access to anothers PC
as above but add nc -lvp (port) -e cmd.exe
once you get the cmd prompt wack in calc and hit enter a couple of times you should see it popup on the clients PC
you are able to run commands under there permission set!
this can also be run between windows and linux.
Contains the usual ethereal , ngrep, nmap , showtraf, tcpdump
here : https://drive.google.com/file/d/1emBK65KcZ0Tv2Xj6xVOAqUw2pmTCWFvC/view?usp=sharing
however these apps were compiled with the SDK Packet Sniffer librarys so all you need is the .exe files there is no need to install the pcap library making these tools perfect for running on your server or alike without installing / moding the existing setup.
http://tigger-and-eric.co.uk/forum/Attachments/packetstuff.zip
#######################
packetyzer
------------------------
'put your domains in below
domains = Array("int", "sussex")
For Each domain In domains
Wsc<x>ript.Echo "*********** Querying: " & domain & " *************"
getdomaininfo domain
Wsc<x>ript.echo
Next
Sub getdomaininfo(domain)
'needed for the gc queries
On Error Resume Next
Set objRootDSE = Getob<x>ject("LDAP://" & domain & "/rootDSE")
'ugly code follows...
Set objSchema = Getob<x>ject _
("LDAP://" & objRootDSE.Get("schemaNamingContext"))
strSchemaMaster = objSchema.Get("fSMORoleOwner")
Set objNtds = Getob<x>ject("LDAP://" & strSchemaMaster)
Set objComputer = Getob<x>ject(objNtds.Parent)
Wsc<x>ript.Echo "Forest-wide Schema Master FSMO: " & objComputer.Name
Set objNtds = Nothing
Set objComputer = Nothing
Set objPartitions = Getob<x>ject("LDAP://CN=Partitions," & _
objRootDSE.Get("configurationNamingContext"))
strDomainNamingMaster = objPartitions.Get("fSMORoleOwner")
Set objNtds = Getob<x>ject("LDAP://" & strDomainNamingMaster)
Set objComputer = Getob<x>ject(objNtds.Parent)
Wsc<x>ript.Echo "Forest-wide Domain Naming Master FSMO: " & objComputer.Name
Set objDomain = Getob<x>ject _
("LDAP://" & objRootDSE.Get("defaultNamingContext"))
strPdcEmulator = objDomain.Get("fSMORoleOwner")
Set objNtds = Getob<x>ject("LDAP://" & strPdcEmulator)
Set objComputer = Getob<x>ject(objNtds.Parent)
Wsc<x>ript.Echo "Domain's PDC Emulator FSMO: " & objComputer.Name
Set objRidManager = Getob<x>ject("LDAP://CN=RID Manager$,CN=System," & _
objRootDSE.Get("defaultNamingContext"))
strRidMaster = objRidManager.Get("fSMORoleOwner")
Set objNtds = Getob<x>ject("LDAP://" & strRidMaster)
Set objComputer = Getob<x>ject(objNtds.Parent)
Wsc<x>ript.Echo "Domain's RID Master FSMO: " & objComputer.Name
Set objInfrastructure = Getob<x>ject("LDAP://CN=Infrastructure," & _
objRootDSE.Get("defaultNamingContext"))
strInfrastructureMaster = objInfrastructure.Get("fSMORoleOwner")
Set objNtds = Getob<x>ject("LDAP://" & strInfrastructureMaster)
Set objComputer = Getob<x>ject(objNtds.Parent)
Wsc<x>ript.Echo "Domain's Infrastructure Master FSMO: " & objComputer.Name
'check for global catalogs
Const NTDSDSA_OPT_IS_GC = 1
Set objGC = Getob<x>ject("LDAP://OU=Domain Controllers," & _
objRootDSE.Get("defaultNamingContext"))
For Each gc In objGC
'clean up the ldap response
gc = Replace(gc.name, "CN=", "")
Set objRootDSE = Getob<x>ject("LDAP://" & gc & "/rootDSE")
strDsServiceDN = objRootDSE.Get("dsServiceName")
Set objDsRoot = Getob<x>ject("LDAP://" & gc & "/" & strDsServiceDN)
'this doesnt always exist therefore we have to use on error resume next
intOptions = objDsRoot.Get("options")
'check to see if the previous command failed with the err.number function
If intOptions And NTDSDSA_OPT_IS_GC and err.Number = 0 Then
Wsc<x>ript.Echo gc & " is a global catalog server."
Else
Wsc<x>ript.Echo gc & " isnt up or isnt a global catalog server."
Err.Clear
End If
next
End Sub 'getdomaininfo
------------------------------------------------
The FSMO role holders can be easily found by use of the Netdom command.
Netdom.exe is a part of the Windows 2000/XP/2003 Support Tools. You must either download it separately (from here Download Free Windows 2000 Resource Kit Tools) or by obtaining the correct Support Tools pack for your operating system. The Support Tools pack can be found in the SupportTools folder on your installation CD (or you can Download Windows 2000 SP4 Support Tools, Download Windows XP SP1 Deploy Tools).
1. On any domain controller, click Start, click Run, type CMD in the Open box, and then click OK.
2. In the Command Prompt window, type netdom query /domain:<domain> fsmo (where <domain> is the name of YOUR domain).
C:WINDOWS>netdom query /domain:yourdomain fsmo
Schema owner server1.yourdomain.net
Domain role owner server1.yourdomain.net
PDC role server1.yourdomain.net
RID pool manager server1.yourdomain.net
Infrastructure owner server1.yourdomain.net
The command completed successfully.
Finding the RID Master, PDC Emulator, and Infrastructure Masters via GUI
To find out who currently holds the Domain-Specific RID Master, PDC Emulator, and Infrastructure Master FSMO Roles:
1. Open the Active Directory Users and Computers snap-in from the Administrative Tools folder.
2. Right-click the Active Directory Users and Computers icon again and press Operation Masters.
fsutil file createnew winaero2.bin 409600000
the above will create a 400mb file (instantly) this in affect is great for reserving space on a drive or file system and or for testing quota's