Tag: Windows

  • How to Reset Windows Password in Linux Rescue

    How to Reset Windows Password in Linux Rescue

    If you lost your windows user password, you can boot into Linux Live CD or Rescue CD and reset your Windows password as follows. Most VPS and dedicated server providers have the option to boot your server into rescue mode.

    Install required packages

    apt-get install chntpw ntfs-3g

    Find the Windows partition and mount it

    mount -t ntfs /dev/nvme0n1p1 /mnt

    If you get error while mounting, see NTFS The disk contains an unclean file system.

    Go to the directory where Windows Password is stored

    cd /mnt/Windows/System32/config

    To list available users, run

    chntpw -l SAM

    To reset the password for a user, run

    chntpw -u USER_NAME_HERE SAM

    Select option 1

     1 - Clear (blank) user password

    This will set the Windows password for the user to blank.

    Next select option 2.

     2 - Unlock and enable user account [probably locked now]

    It will change to

    (2 - Unlock and enable user account) [seems unlocked already]

    Select option q to quit.

     q - Quit editing user, back to user select

    It will ask you to save changes, press “y” to save.

    root@vmi1255071:/mnt/Windows/System32/config# chntpw -u Administrator SAM
    chntpw version 1.00 140201, (c) Petter N Hagen
    Hive  name (from header): <\SystemRoot\System32\Config\SAM>
    ROOT KEY at offset: 0x001020 * Subkey indexing type is: 666c 
    File size 262144 [40000] bytes, containing 7 pages (+ 1 headerpage)
    Used for data: 298/26896 blocks/bytes, unused: 16/1552 blocks/bytes.
    
    ================= USER EDIT ====================
    
    RID     : 0500 [01f4]
    Username: Administrator
    fullname: 
    comment : Built-in account for administering the computer/domain
    homedir : 
    
    00000220 = Administrators (which has 1 members)
    
    Account bits: 0x0010 =
    [ ] Disabled        | [ ] Homedir req.    | [ ] Passwd not req. | 
    [ ] Temp. duplicate | [X] Normal account  | [ ] NMS account     | 
    [ ] Domain trust ac | [ ] Wks trust act.  | [ ] Srv trust act   | 
    [ ] Pwd don't expir | [ ] Auto lockout    | [ ] (unknown 0x08)  | 
    [ ] (unknown 0x10)  | [ ] (unknown 0x20)  | [ ] (unknown 0x40)  | 
    
    Failed login count: 19, while max tries is: 0
    Total  login count: 15
    ** No NT MD4 hash found. This user probably has a BLANK password!
    ** No LANMAN hash found either. Try login with no password!
    
    - - - - User Edit Menu:
     1 - Clear (blank) user password
     2 - Unlock and enable user account [probably locked now]
     3 - Promote user (make user an administrator)
     4 - Add user to a group
     5 - Remove user from a group
     q - Quit editing user, back to user select
    Select: [q] > 1
    Password cleared!
    ================= USER EDIT ====================
    
    RID     : 0500 [01f4]
    Username: Administrator
    fullname: 
    comment : Built-in account for administering the computer/domain
    homedir : 
    
    00000220 = Administrators (which has 1 members)
    
    Account bits: 0x0010 =
    [ ] Disabled        | [ ] Homedir req.    | [ ] Passwd not req. | 
    [ ] Temp. duplicate | [X] Normal account  | [ ] NMS account     | 
    [ ] Domain trust ac | [ ] Wks trust act.  | [ ] Srv trust act   | 
    [ ] Pwd don't expir | [ ] Auto lockout    | [ ] (unknown 0x08)  | 
    [ ] (unknown 0x10)  | [ ] (unknown 0x20)  | [ ] (unknown 0x40)  | 
    
    Failed login count: 19, while max tries is: 0
    Total  login count: 15
    ** No NT MD4 hash found. This user probably has a BLANK password!
    ** No LANMAN hash found either. Try login with no password!
    
    - - - - User Edit Menu:
     1 - Clear (blank) user password
     2 - Unlock and enable user account [probably locked now]
     3 - Promote user (make user an administrator)
     4 - Add user to a group
     5 - Remove user from a group
     q - Quit editing user, back to user select
    Select: [q] > 2
    Unlocked!
    ================= USER EDIT ====================
    
    RID     : 0500 [01f4]
    Username: Administrator
    fullname: 
    comment : Built-in account for administering the computer/domain
    homedir : 
    
    00000220 = Administrators (which has 1 members)
    
    Account bits: 0x0210 =
    [ ] Disabled        | [ ] Homedir req.    | [ ] Passwd not req. | 
    [ ] Temp. duplicate | [X] Normal account  | [ ] NMS account     | 
    [ ] Domain trust ac | [ ] Wks trust act.  | [ ] Srv trust act   | 
    [X] Pwd don't expir | [ ] Auto lockout    | [ ] (unknown 0x08)  | 
    [ ] (unknown 0x10)  | [ ] (unknown 0x20)  | [ ] (unknown 0x40)  | 
    
    Failed login count: 0, while max tries is: 0
    Total  login count: 15
    ** No NT MD4 hash found. This user probably has a BLANK password!
    ** No LANMAN hash found either. Try login with no password!
    
    - - - - User Edit Menu:
     1 - Clear (blank) user password
    (2 - Unlock and enable user account) [seems unlocked already]
     3 - Promote user (make user an administrator)
     4 - Add user to a group
     5 - Remove user from a group
     q - Quit editing user, back to user select
    Select: [q] > q
    
    Hives that have changed:
     #  Name
     0  
    Write hive files? (y/n) [n] : y
     0   - OK
    root@vmi1255071:/mnt/Windows/System32/config# 

    Now you need to log in to the server using the console, it won’t ask for any password. Once logged in, you can set a password for the user. You can’t log in using RDP with a blank password.

    After the password reset, “chntpw -l SAM” will look like the following

    root@vmi1255071:/mnt/Windows/System32/config# chntpw -l SAM
    chntpw version 1.00 140201, (c) Petter N Hagen
    Hive  name (from header): <\SystemRoot\System32\Config\SAM>
    ROOT KEY at offset: 0x001020 * Subkey indexing type is: 666c 
    File size 262144 [40000] bytes, containing 7 pages (+ 1 headerpage)
    Used for data: 298/26896 blocks/bytes, unused: 16/1552 blocks/bytes.
    
    | RID -|---------- Username ------------| Admin? |- Lock? --|
    | 01f4 | Administrator                  | ADMIN  | *BLANK*  |
    | 01f5 | Guest                          |        | dis/lock |
    root@vmi1255071:/mnt/Windows/System32/config# 

    Back to Windows

  • Nginx on Windows

    You can download nginx for windows from

    https://nginx.org/en/download.html

    To download nginx from command line, use following command in PowerShell

    Invoke-WebRequest -Uri https://nginx.org/download/nginx-1.19.6.zip -OutFile nginx-1.19.6.zip
    

    Auto Start Nginx on Windows

    When using Nginx on Windows, you need to escape paths with \ like following

    root C:\\sites\\my-site;
    

    For SSL, i used

    listen 443 ssl http2;
    ssl_certificate C:\\nginx\\ssl\\crt\\dedi.ai-chain.pem;
    ssl_certificate_key C:\\nginx\\ssl\\crt\\dedi.ai-key.pem;
    

    See Nginx

  • Downloading a file with PowerShell

    To download a file using PowerShell, run

    Invoke-WebRequest -Uri URL_HERE -OutFile FILE_NAME_HERE
    

    Example

    Invoke-WebRequest -Uri http://nginx.org/download/nginx-1.17.10.zip -OutFile nginx-1.17.10.zip
    

    See Windows

  • Delete SSL Certificate in IIS

    To delete SSL certficate in IIS,

    1) Start Internet Information Service (IIS) Manager
    2) Click on Server Name (server hostname)
    3) On right side, click on Server Certificates button.

    On next screen, you will get a list of all SSL certfificates. You can right click on any of the certficate and delete it.

    For older version of IIS

    1) Open MMC (Start > Run > MMC). Open the Certificates Snap-in.
    2) Select Local Computer Account
    3) Select Certificates > Personal
    4) Find the certficate and delete.

    See Internet Information Server (IIS)

  • Auto Start Nginx on Windows

    To auto start Nginx on Windows, download

    http://nssm.cc/download

    Extract the file, you will find “nssm.exe” file for 32 and 64 bit windows. Copy the file for your Windows version to a folder like

    C:\utils\nssm.exe

    Start a command promt as user Administrator, then to go the folder where nssm.exe is, then run

    .\nssm.exe install “Nginx”"
    

    In the GUI select the nginx.exe path, click install service.

    Now in Service Manager, you will see new service Nginx, that is set to autostart by default.

    You can right click service name and select start.

    See Windows Nginx

  • Find Windows Server version from command line

    To find windows server version from command line, run

    gwmi win32_operatingsystem | % caption
    

  • Generate CSR on Microsoft Windows Server

    Generate CSR: IIS 6 Microsoft Windows Server 2003

    Open the Internet Information Services (IIS) Manager. From the Start button select Programs > Administrative Tools > Internet Information Services Manager.
    In IIS Manager, double-click the local computer, and then double-click the Web Sites folder.
    Right-click the Web site for which you want to request a certificate, and then click Properties. By default it will be Default Web Site, yours may be different.

    Select the Directory Security tab and click Server Certificate in the Secure communications section.

    Click Next in the Welcome to the Web Server Certificate Wizard window.

    Select Create a new certificate, Click Next.

    Select Prepare the request now, but send it later.

    At the Name and Security Settings screen, fill in the friendly name field for the new certificate

    Select bit length. We recommend using a 2048-bit length (2048 is required for EV SSL). Click Next.

    Leave the ‘Select cryptographic service provider (CSP) for this certificate’ unchecked. Click Next.

    You will be asked for several pieces of info which will be used by GeoTrust to create your new SSL certificate. These fields include the Common Name (aka domain, FQDN), organization, country, key bit length, etc. Use the CSR Legend in the right-hand column of this page to guide you when asked for this information. The following characters should not be used when typing in your CSR input: < > ~ ! @ # $ % ^ / \ ( ) ? , &

    Enter your Organization (e.g., Gotham Books Inc) and Organizational Unit (e.g., Internet Sales). Click Next.

    THIS IS THE MOST IMPORTANT STEP! Enter your site’s Common Name. The Common Name is the fully-qualified-domain name for your web site or mail server. What ever your end-user will see in their browser’s address bar is what you should put in here. Do not include http:// nor https://. Refer to the CSR legend in the right-hand column of this page for examples. If this is wrong, your certificate will not work properly. Click Next.

    Enter your Geographical Information for Country, State, and City. Do not abbreviate States and Cities. Click Next.

    In the Certificate Request File Name box enter the path and file name where you want to save your CSR. You can use the default of c:\certreq.txt. Remember where you save it, you’ll need to be able to find this CSR file later. Click Next.

    Review the data on the Request File Summary screen and click Next.

    Click Finish to complete the Wizard.

    Now, from a simple text editor such as Notepad (do not use Word), open the CSR file you just created at c:\certreq.txt (your path/filename may be different). You will need to copy-and-paste the contents of this file

    See SSL

  • Change Unidentified Network from public in windows 7

    After upgrading Main computer (one that connect to DSL modem) on LAN, other PC’s are able to get internet. But failed to ping on 192.168.0.1.

    Method 1

    Go to

    Start > Search > secpol.msc
    

    Navigate to

    Network List Manager Policies > Unidentified Networks
    

    Double Click and Change Location Type to

    Private
    

    Warning This means from now on all Unidentified Networks will be set as private!!

    Method 2

    NOTE: This is temporary solution, on rebooting, changes will be lost

    This is caused by Network card that connect to lan with IP 192.168.0.1 is assigned as a “Public Network”. Public Network have many features disabled for security.

    To fix this, run “ChangeCategory.psl” on Power Shell running as Administrator.

    Copy and paste following content to a text file, save it as ChangeCategory.psl

    $NLMType = [Type]::GetTypeFromCLSID('DCB00C01-570F-4A9B-8D69-199FDBA5723B')
    $INetworkListManager = [Activator]::CreateInstance($NLMType)
    
    $NLM_ENUM_NETWORK_CONNECTED  = 1
    $NLM_NETWORK_CATEGORY_PUBLIC = 0x00
    $NLM_NETWORK_CATEGORY_PRIVATE = 0x01
    $UNIDENTIFIED = "Unidentified network"
    
    $INetworks = $INetworkListManager.GetNetworks($NLM_ENUM_NETWORK_CONNECTED)
    
    foreach ($INetwork in $INetworks)
    {
        $Name = $INetwork.GetName()
        $Category = $INetwork.GetCategory()
    
        if ($INetwork.IsConnected -and ($Category -eq $NLM_NETWORK_CATEGORY_PUBLIC) -and ($Name -eq $UNIDENTIFIED))
        {
            $INetwork.SetCategory($NLM_NETWORK_CATEGORY_PRIVATE)
        }
    }
    

    Now run power shell as administrator.

    Type

    set-executionpolicy remotesigned
    ChangeCategory.ps1 
    

    This should be done in folder where ChangeCategory.ps1 is saved.

    PowerShell change network

    After doing this, Network and Sharing Center will show

    Undefined Network

    Windows Firewall will show “undefined network” in “Home or work (private) networks”. Being in private network, you get privileges to share, ping etc…

    See Windows