GNS3 file transfer to or from appliance in VM

Read More

The method described uses WinSCP

  • Install SCP client if needed
  • Identify GNS3 VM url
  • You get the url, file path and user at VM opening

  • Open SCP connection to GNS3 VM
  • User: gns3 Password: gns3

  • Navigate to identify instance of appliance in /root/..
  • It is easy to identify the project files with the date of last modification. In this specific case, we are going to get a downloaded file from a router through Webterm (a docker containing Firefox that can be added to GNS3). You get the id of the instance of the object inside the project hovering over it in GNS3. The file is downloaded in a folder of the docker.

  • Modify permissions
  • Open docker file handler to modify permissions of root folder

QR for fast WiFi access

Download a QR generator program: Download QR Code Studio
Optionally, you can use an online service to generate the QR at your own risk.
Feed this text adapted to your needs:

WIFI:S:My_SSID;T:WPA;P:key goes here;H:false;

Code type
ESSID
encryption type
WPA key
hidden SSID (true/false)

If needed, escape any special characters (“, ‘, ;, ,, or \) with a backslash

Using touch command

Read More

touch Creates a file without content

touch file_name

For multiple files

touch File_name1 File2_name2 File_name3

Running touch on an already existing file: the file’s access and modification timestamps are updated to the current time, the content is not modified

touch -a To modify the access time only

touch -a file_name

touch -am Change access and modification time together

touch -am file_name

touch -c To check if file is created or not

touch -c file_name

-d option Use string with date instead of current time
touch -c -d "2020-03-09 11:33:12.000000000 +0100" file_name
-t option Use timestamp instead of current time. Format [[CC]YY]MMDDhhmm[.ss] touch -c -t 202003091133 file_name

touch -m This is used to change the modification time only
touch -m file_name

touch -r This command is used to copy only the timestamp onto another file

touch -r reference_file_name target_file_name

touch -h For modifying a symbolic link, not the pointed to

touch -h symbolic_link_file

Create several files touch

# Create files with names A to Z
$ touch {A..Z}
# Create files with names 1 to 20
$ touch {1..20}
# Create files with extension
$ touch {1..1000}.txt
# Create 10K files
$ touch {1..10}{1..1000}

Using touch to restore timestamps in a directory tree

To change all the directories to 755 (drwxr-xr-x):

find /opt/lampp/htdocs -type d -exec chmod 755 {} \;

To change all the files to 644 (-rw-r–r–):

find /opt/lampp/htdocs -type f -exec chmod 644 {} \;

And to change file and directories timestamp

find . -exec touch {} \;

Only files

find . -type f -exec touch {} \;

Mount a deviceless webdav connection in Windows 10

Mount deviceless webdav
This type of connection cannot be persistent
net use http://domain/directory/ paasword /USER:user
Access
It is necessary to use MS \\server\resource notation
dir \\domain\directory
Mount with first unallocated unit letter
net use * http://domain/directory/ paasword /USER:user
Mount with specific drive
net use x: http://domain/directory/ paasword /USER:user
Unmount

net use http://domain/directory/ /delete
net use x: /delete

Caution:
net use * /delete
deletes all connections

Net Use Command Options
Option Explanation
net use Execute the net use command alone to show detailed information about currently mapped drives and devices.
devicename Use this option to specify the drive letter or printer port you want to map the network resource to. For a shared folder on the network, specify a drive letter from D: through Z:, and for a shared printer, LPT1: through LPT3:. Use * instead of specifying devicename to automatically assign the next available drive letter, starting with Z: and moving backward, for a mapped drive.
\\computername\sharename This specifies the name of the computer, computername, and the shared resource, sharename, like a shared folder or a shared printer connected to computername. If there are spaces anywhere here, be sure to put the entire path, slashes included, in quotes.
volume Use this option to specify the volume when connecting to a NetWare server.
password This is the password needed to access the shared resource on computername. You can choose to enter the password during the execution of the net use command by typing * instead of the actual password.
/user Use this net command option to specify a username to connect to the resource with. If you don’t use /user, net use will attempt to connect to the network share or printer with your current username.
domainname Specify a different domain than the one you’re on, assuming you’re on one, with this option. Skip domainname if you’re not on a domain or you want net use to use the one you’re already on.
username Use this option with /user to specify the username to use to connect to the shared resource.
dotteddomainname This option specifies the fully qualified domain name where username exists.
/home This net use command option maps the current user’s home directory to either the devicename drive letter or the next available drive letter with *.
/persistent:{yes | no} Use this option to control the persistence of connections created with the net use command. Choose yes to automatically restore created connections at the next login or choose no to limit the life of this connection to this session. You can shorten this switch to /p if you like.
/smartcard This switch tells the net use command to use the credentials present on the available smart card.
/savecred This option stores the password and user information for use next time you connect in this session or in all future sessions when used with /persistent:yes.
/delete This net use command is used to cancel a network connection. Use /delete with devicename to remove a specified connection or with * to remove all mapped drives and devices. This option can be shortened to /d.
/help Use this option, or the shortened /h, to display detailed help information for the net use command. Using this switch is the same as using the net help command with net use: net help use.
/? The standard help switch also works with the net use command but only displays the command syntax, not any detailed information about the command’s options.

Run Powershell script Windows 10

Read More

Create Script

Search for Windows PowerShell ISE and run the integrated editor.
Click on File menu.
Select the New option to create a new empty .ps1 file

Verify execution Policy

Run powershell as administrator.
Set-ExecutionPolicy RemoteSigned
On Windows 10, PowerShell includes four execution policies, including:

  • Restricted — Stops any script from running.
  • RemoteSigned — Runs scripts created on the device. However, scripts created on another computer won’t run unless they include a signature of a trusted publisher.
  • AllSigned — All the scripts will run as long as they’ve been signed by a trusted publisher.
  • Unrestricted — Runs any script without any restrictions.

Execute script

Execute command
& "C:\PATH\TO\SCRIPT\name_of_script.ps1"

Add Command Prompt As Administrator Context Menu in Windows 10

Read More

Create .reg file and execute with content:

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\OpenElevatedCmd] @="Open command prompt here as administrator"
"Icon"="cmd.exe"
[HKEY_CLASSES_ROOT\Directory\shell\OpenElevatedCmd\command] @="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/k,pushd,%V' -Verb RunAs\""
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenElevatedCmd] @="Open command prompt here as administrator"
"Icon"="cmd.exe"
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenElevatedCmd\command] @="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/k,pushd,%V' -Verb RunAs\""
[HKEY_CLASSES_ROOT\Drive\shell\OpenElevatedCmd] @="Open command prompt here as administrator"
"Icon"="cmd.exe"
[HKEY_CLASSES_ROOT\Drive\shell\OpenElevatedCmd\command] @="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/k,pushd,%V' -Verb RunAs\""
[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenElevatedCmd] @="Open command prompt here as administrator"
"Icon"="cmd.exe"
[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenElevatedCmd\command] @=

User management in Ubuntu

Show last user logins into the system
lastlog | less
Currently logged in users in the system
who

Add new user
adduser username usergroupname (perl calling useradd)
useradd username

Delete user
userdel username
userdel -r username removing home directory

deluser with /etc/deluser.conf (Debian and derivatives)
deluser --remove-home

 

 

Windows 10 Add better sendto functionality

Read More

Adds multiple file send to functionality
Create SendToMailRecipient.vbs somewhere executable with the code below
Create a shortcut link to it
Put the link in the directory opened with shell:sendto

Option Explicit
Dim objArgs, OutApp, oNameSpace, oInbox, oEmailItem, olMailItem
Dim a, oAttachments, subjectStr, olFormatHTML
olMailItem = 0
olFormatHTML = 2
Set objArgs = WScript.Arguments 'gets paths of selected files
Set OutApp = CreateObject("Outlook.Application") 'opens Outlook
Set oEmailItem = OutApp.CreateItem(olMailItem) 'opens new email
For a = 0 to objArgs.Count - 1
Set oAttachments = oEmailItem.Attachments.Add(objArgs(a))
subjectStr = subjectStr & Right(objArgs(a),Len(objArgs(a))-(InStrRev(objArgs(a),"\"))) & ", " 'recreates the default Subject e.g. Emailing: file1.doc, file2.xls
Next
If subjectStr = "" then subjectStr = "No Subject "
oEmailItem.Subject = "Emailing: " & Left(subjectStr, (Len(subjectStr)-2))
oEmailItem.BodyFormat = olFormatHTML
oEmailItem.Display

Inverse selection in File Explorer

Read More

Use Invert Selection for Easier File Selection in Windows Explorer

The next time you need to select most of the files in an open Explorer window don’t waste your time holding down Ctrl and clicking each file manually. It’s much easier to select the ones you DON’T need, and then let Windows reverse your selection.

Inside an open window, hold down Ctrl as you select the file(s) you DON’T want to select (sounds backward, but wait…).

Select Edit, then Invert Selection, and Windows will turn your selection inside out leaving you with the files you wanted to select.

You can then delete or copy them as needed.