Sunday, December 27, 2020

Create a bootable USB stick with PowerShell (Create-BootableUSBStick)

 

Create a bootable USB stick with PowerShell (Create-BootableUSBStick)

Creating a bootable USB stick could be a tricky task. You’ll need a tool (eg. the Windows 7 USB/DVD tool) or you have to struggle with those old cmd commands like bootsect.exe. This is now over, because I’ve created a PowerShell function for the community that automates all the steps you need for creating your Windows 10 or Windows Server bootable USB stick.

Create-BootableUSBStick in Action

I want to show you first what we are going to achieve.

Plug in your USB stick. Then mount the operating system iso file (Windows 7/8/10, Windows Server). Double check the drive letters. We’ll need them further on.

In my case the USB stick is associated with E: and the ISO is mounted on F:. The following command sets up an bootable Windows USB stick:

1
Create-BootableUSBStick -USBDriveLetter E: -ImageFiles F:

1.PNG

Now wait a few minutes and your USB stick is ready to use!

The Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function Create-BootableUSBStick {
 
# .SYNOPSIS
# Create-BootableUSBStick is an advanced PowerShell function to create a bootable USB stick for the installation of Windows OS.
 
# .DESCRIPTION
# The main idea is to avoid the use of 3rd party tools or tools like the Windows 7 USB tool.
 
# .PARAMETER
# USBDriveLetter
# Mandatory. Provide the drive letter where your usb is connected
 
# .PARAMETER
# ImageFiles
# Mandatory. Enter the drive letter of your mounted ISO (OS Files)
 
# .EXAMPLE
# Create-BootableUSBStick -USBDriveLetter F: -ImageFiles D:
 
# .NOTES
# Author:Patrick Gruenauer
 
[CmdletBinding()]
 
param
 
(
 
[Parameter()]
$USBDriveLetter,
 
[Parameter()]
$ImageFiles
 
)
 
$USBDriveLetterTrim=$USBDriveLetter.Trim(':')
 
Format-Volume -FileSystem NTFS -DriveLetter $USBDriveLetterTrim -Force
 
bootsect.exe /NT60 $USBDriveLetter
 
xcopy ($ImageFiles +'\') ($USBDriveLetter + '\') /e
 
Invoke-Item $USBDriveLetter
 
}

How to use it

Copy the code into your PowerShell ISE session and run the code. Then type the command and have fun with it.

If you want to make the function permanent available, so that the function is there every time you start PowerShell, you have to create a folder in C:\Program Files\WindowsPowerShell\Modules. Name it Create-BootableUSBStick. Then save the code as a .psm1 file in that folder. The screenshot below will be a great help.

2.png

Share this:

Wednesday, December 23, 2020

Printer mapping - batch script

 @echo off
net time \\dell /set /yes
net use o:\\dell\admin\office
net use s: \\dell\Sims$
net use t: \\dell\shared
start \\dell\office_laser_printer
start \\dell\ict_mono_laser_1
start \\dell\ict_mono_laser_2
start \\dell\ks1_colour_laser
start \\dell\ks1_mono_laser
start \\dell\lz_mono_laser

Tuesday, December 22, 2020

Printer mapping - vbs script

 'CREATE NETWORK OBJECTS
Set mWSHNetwork = CreateObject("WScript.Network")
Set mExisitingMappedDrives = mWSHNetwork.EnumNetworkDrives
Set existingPrinters = mWSHNetwork.EnumPrinterConnections
Set mFileSystemObject = CreateObject("Scripting.FileSystemObject")
Set objExplorer = CreateObject("InternetExplorer.Application")
 

'PRINTERS (Ex. "\\<print server name>\<Queue Name>)
defaultPrinters = "\\<print server name>\Canon iR5000 - FC2 Left;
\\<print server name>\Canon iR5070 - Right;
\\<print server name>\RICOH MP 6001 Breakroom;
\\<print server name>\Canon iR5070 - NJ;
\\<print server name>\RICOH  MP 6001 Sales;
\\<print server name>\RICOH  MP 6001 Referral;
\\<print server name>\RICOH Aficio MP 6000 - Litigation Area "

Mapping printers - vbs script

 ' Printers.vbs - Windows Logon Script.
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection "\\FileServer01\HP4050"

Linux Hacking Exposed - Notes

 Linux Hacking Exposed

- attack NFS shares
- SQUID proxy (attacking proxy)
- Windows X System TCP port 6000->6003
xhost+
- sniffers: tcpdump
- vulnerable scripts: count.cgi, php.cgi, nph.cgi, nph-test.cgi
- netstat -an command
- nmap -sT -O localhost

- setuserid programs run with the effective user ID that owns the file

cp 'which id'
chown root ./id
chmod 755 ./id; chmod u+s ./id
ls -l ./id
id
./id

- find ways to abuse users with '.' in their PATH
- passwords stored in user files
- passwords stored in System Files
ex: /etc/ppp/chap-secrets file
/etc/wvdial.conf

Sudo:
- a tool for distributing administrative authority
- using sudo, is possible to grant specific users the ability to perform specific administrative tasks that normally require ROOT access

- symlink and hardlink attacks
- wc -l /etc/shadow