How to install OpenSSH on Windows 7 / 10

Use SSH on Windows, how running/launching graphical programs on remote computer in the same user session logon on Windows OS.

Requirements:
– OpenSSH (you can download the binaries from the official repository on github https://github.com/PowerShell/Win32-OpenSSH/releases)
– PsTools (official useful tools from Microsoft https://docs.microsoft.com/en-us/sysinternals/downloads/pstools)
– PowerShell

Install Pstools (by microsoft)

  1. Download the tools
  2. Copy the content of the folder PSTools under “C:\Windows\System32\”.
  3. Open the cmd as administrator and run C:\Windows\System32\psexec.exe, accept the eula license.

Install SSH Server on Windows 7 / 10

  1. Download the latest OpenSSH for Windows binaries (package OpenSSH-Win64.zip or OpenSSH-Win32.zip)
  2. As the Administrator, extract the package to %PROGRAMFILES%\OpenSSH
    note: the folder must be named “OpenSSH”
  3. Open PowerShell as the Administrator (right click on PowerShell icon, “run as administrator”), change directory to “C:\Program Files\OpenSSH” install sshd and ssh-agent services with the command
    > cd “%PROGRAMFILES%\OpenSSH”
    > powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps
  4.  Allow incoming connections to SSH server in Windows Firewall:
    – Either run the following PowerShell command (Windows 8 and 2012 or newer only), as the Administrator:

    New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22

    – or go to Control Panel > System and Security > Windows Firewall> Advanced Settings > Inbound Rules and add a new rule for port 22.

  5. Start the service and/or configure automatic start:
    ◦ Go to Control Panel > System and Security > Administrative Tools and open Services. Locate sshd service.
    ◦ If you want the server to start automatically when your machine is started: Go to Action > Properties. In the Properties dialog, change Startup type to Automatic and confirm.
    ◦ Start the sshd service by clicking the Start the service.
  6. Create the ~./.ssh folder under C:\Users\<user>\.ssh

  7. Create the file “authorized_keys” under ~./.ssh

  8. Run the scrips to fix/check correct permission a PowerShell with administrator privilege.

    > powershell.exe -ExecutionPolicy Bypass -File FixHostFilePermissions.ps1
    > powershell.exe -ExecutionPolicy Bypass -File FixUserFilePermissions.ps1
  9. Personalize your SSH server settings editing the configuration file %PROGRAMDATA%\ssh\sshd_config.

Install SSH Client on Windows 7 / 10

  1. Do the step from 1 to 2 from the above paragraph “Install SSH Server on Windows 7 / 10”

Enable public keys without using password on client

  1. Open cmd.exe as Administrator and run ssh-keygen.exe and press enter to all message for default configuration
> cd “%PROGRAMFILES%\OpenSSH”
> ./ssh-keygen.exe

Enable public keys without using password on Server

  1. Copy the private and public key on the ~.ssh folder of the user that you want use on the server.Run ssh-add.exe to add you private and public key to the ssh-agent.
    Note: ensure that ssh-agent is running.

    > ./ssh-add.exe

Run graphical programs on remote computer with Windows using psexec.exe

Connect to the remote machine with ssh and run notepad.exe on the remote computer in the same user sessions opened

> cd “%PROGRAMFILES%\OpenSSH”
> ssh.exe [remote_local_user]@[remote_ip] -i “C:\Users\\.ssh\id_rsa”
user@remote_ip> psexec.exe \\127.0.0.1 -d -i -s notepad.exe

 

PHP Access To An MSSQL Database From Debian with ODBC And FreeTDS

Note:  on some Ubuntu system you could incur on issues (Data source name not found, and no default driver specified)

First install the necessary packages:

# apt-get install tdsodbc unixodbc php5-odbc

ODBC Driver registration:

# nano /etc/freetds/tds.driver.template
[FreeTDS]
Description = ciao
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Seteup = /usr/lib/x86_64-inux-gnu/odbc/libtdsS.so

Now the edit the DSN file:

# nano /etc/freetds/tds.dsn.template

Replace the <...> with your settings.

[MSSQL]
Driver = FreeTDS
Description = <Description>
Server = <IP>
Port = 1433
Database = <DatabaseName>

Ok, now you need to get these templates inserted into the unixODBC system:

# odbcinst -i -d -f /etc/freetds/tds.driver.template
# odbcinst -i -s -f /etc/freetds/tds.dsn.template

check file permission of /etc/odbc.ini and /etc/odbcinit.ini

check php extension /etc/php5/mods-available/odbc.ini

; configuration for php ODBC module
; priority=20
extension=odbc.so

test connection
# isql -v MSSQL user pwd

Test PHP connection  to MS SQL server by example:

<?php

# connect to a DSN "DSN_NAME" with a user "Bob" and password "Marley"
$connect = odbc_connect("DSN_NAME", "Bob", "Marley");

# query the users table for all fields
$query = "SELECT * FROM users";

# perform the query
$result = odbc_exec($connect, $query);

# fetch the data from the database
while(odbc_fetch_row($result)) {
$field1 = odbc_result($result, 1);
$field2 = odbc_result($result, 2);
print("$field1 $field2\n");
}

# close the connection
odbc_close($connect);

?>

Fix NET::LDAP:Error Login in OpenProject 7.4.6

If you upgrade OpenProject from 6 to 7 maybe you will have some trouble with SSL certificate.

Symptons

– can’t login into openproject with LDAP method configured

After the upgrade the log reports:

"NET::LDAP:Error (hostname "yourhostname" does not match the server certificate)".

After some emails with openporject support we did not find any solutions, so i decided to investigate and find a workaround. I had a server CentOS 7 with openproject 6 and a self signed certicate installed.

How to fix

To fix the login error i have commented the line 291 in the file /opt/openproject/vendor/ruby-2.4.4/lib/ruby/2.4.0/ssl.rb near the line “raise SSLError…”

Unless OpenSSL::SSL.verify_certificate_identity(peer_cert, hostname)

# raise SSLError, "hostname \"#{hostname}\" does not match the server certificate"

end

So i do not throw the exception if the SSL is not valid. The best solution is to investigate how the check’s function works but if you do not have time the workaround is helpfulest.

How compile and install keePassX 2.0

Compile KeePassX 2.0 on K/Ubuntu 14.04

Download source code: https://www.keepassx.org/downloads, choose “the Source code tarball”.

Prerequisites:

# apt-get install build-essential cmake qt4-qmake libqt4-dev libgcrypt-dev zlib1g-dev

Go in the folder where you downloaded the source code and type following commands:

$ tar -zxvf keepassx-2.0.tar.gz
$ cd keepassx-2.0
$ mkdir build
$ cd build
$ cmake ../
$ make -j 4
$ sudo make install

Number of cyber attacks daily

My personal monitor of cyber attacks

In the last year i have noticed an increase of cyber attacks to my website. I have decided to collect them and make a statistics of attack daily. The first question is “Who do this cyber attack?”. Well, in some cases are just bored people, but in general are automatic programs that search some keywords on all websites and if they find them they try an attack. Another interesting question is the choice of this keyword used by determining which website to attack. For instance the keyword “SAM” is one of the most words searched.

Click on image to view the updated graph
The linear chart shows the number of cyber attacks that receive every day the site fred151.net

Bypass Windows logons with Utilman.exe trick and Solution

Hole security in windows system

Utilman.exe is a Windows application that is designed to allow the user to configure Accessibility options such as the magnifier, High Contrast Theme, Narrator and On screen keyboard before they log onto the system.

This application is run as administrator, so the trick is replace utilman.exe with cmd.exe. You can use a linux distrubution, a windows cd, old bootable floppy disk to access to hard disk and rename utilman.exe to utilman.exe.bak, make a copy of cmd.exe and name it utilman.exe.

The main problem of this trick is that the antivirus or firewall are useless and everyone can modify your computers to obtain more information or run malicious software in your company network.

Example of commands:

> cd C:\Windows\System32
> ren Utilman.exe Utilman.exe.bak
> copy cmd.exe Utilman.exe

Restart your computer and before login press Windows Key +U and you should get a Command Prompt.

You can for example add a new administrator account and after delete it.

> net user Admin admin1234 /add
> net localgroup Administrators Admin /add

Solution

  1. you have to set a password for BIOS and set the primary boot device from your hard disk.
  2. disable the Utilman.exe. To disable utilman.exe before logon i have written a program compatible to all versions of windows 7, 8.

If you want protect your company with my program,please contact me by my online form.

Please leave you company name, number of employed, and your skype contact or phone.

Prime Numbers

“The Music of the Primes”

I’m ever fascinated about sequence numbers and prime numbers. So this is the why of this creation. This is my first program written in language C. All people know the power of prime numbers, they are still using in algorithms to crypt the comunications. A small definition “A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself” that enclosed a powerful magic. the number 2 is the only even prime numbers by definition. I suggest to you a book: Marcus Du Sautoy, “The Music of the Primes”, Fourth Estate.

How works?

Prime Numbers has a simple algorithm that can check all divisors of a number n minor of square root of n, the algorithm don’t check the even numbers. It has a good execution speed. The program was tested on 64 bit architectures. The max range depends of the type of machine you use, in the most cases under UNIX the max range value is 18.446.744.073.709.551.615.

How to use it?

Prime Numbers must be executed by terminal and need some parameters to run good.

Usage: prime_number -f [n] -t [n] -o [file]
Options:
-f Start from [number]
-t Finish to [number]
-o Write on file

-h --help Display this information
-v Active verbose mode, shows prime numbers, else shows a percent

An Example, the prime numbers between 0 and 100:

$ ./prime_number -f 2 -t 100 -o primi.txt

Versions

Prime Numbers v1.2 (x64)

Data: 12/12/2010
Features:

Compiled on Ubuntu 10.10 x64 bit
Parametres by command line

windows(x86) MD5: 15933b7484ae9805596847602ad5b795 prime-numbers_v1.2.zip

Prime Numbers v1.2 (Win x32/x64)

Data: 12/12/2010
Features:

Compiled on virtual machine running windows XP 32 bit
Parametres by command line

linux (x64) MD5: 3a89f6c17d01d5df5bd7500b707524cd prime-numbers_v1.2.tar.gz

How to make a bootable floppy with GRUB

How make a bootable floppy to available partitions linux and windows

This guide is written to start an old notebook with two partitions: Linux and Windows 98. We will use the distribution DSL (Damn Small Linux) because it is one of the lightest distributions in the world. DSL can run on old notebook with 16MB of RAM.
Ok let’s go, download an ISO image of DSL, such as 4.0syslinux, and burn it on CD. Run the CD and install DSL on partition, if you have some trouble or you don’t know how make partitions on HDD (Hard Disk Drive) i suggest to you read my guide “good hack”.

Start DSL and type in console:

$ sudo -s

Now insert a formattated floppy in FAT and type:

# mount /dev/fd0 /mnt/auto/floppy
# mkdir /mnt/auto/floppy/grub

Copy the GRUB files and the startup menu:

# cp /boot/grub/stage* /mnt/auto/floppy/grub
# cp /boot/grub/menu.lst /mnt/auto/floppy/grub

Umount the floppy disk with the following command:

# umount /mnt/auto/floppy

Install stage1 in the MBR (Master Boot Record) sector of floppy disk:

# grub

After you have run grub, write these commands in order, ignoring the messages:

> root (fd0)
> setup (fd0)
> quit

Now we will modify the GRUB configuration by editing the file menu.lst, you can use the editor of Linux or Notepad on a Windows machine.
For editing the file on Linux write in terminal:

# sudo -s
# mount /dev/fd0 /mnt/auto/floppy

Open Emelfm and open the folder “/mnt/auto/floppy/grub” and open the file menu.lst
The file menu.lst should looks like this:

# This sets the default entry to boot.
# Remember that GRUB counts from 0, so 1 is the second entry.
default 0
# This sets the length of time in seconds that grub will wait for the user to select an OS
# before it boots the default on. I reccommend at least 15 seconds.
timeout 15
#Enter the entry for DSL here. Something like this.

title DSL
kernel /boot/linux24 root=/dev/hda5 quiet vga=normal noacpi noapm nodma noscsi frugal
title DSL fb800x600
kernel /boot/linux24 root=/dev/hda5 quiet vga=788 noacpi noapm nodma noscsi frugal

title DSL fb1024x768
kernel /boot/linux24 root=/dev/hda5 quiet vga=791 noacpi noapm nodma noscsi frugal

title DSL fb1280x1024
#kernel /boot/linux24 root=/dev/hda5 quiet vga=794 noacpi noapm nodma noscsi frugal

title DSL with toram, mydsl, restore, hostname, and passwords
kernel /boot/linux24 root=/dev/hda5 quiet vga=normal noacpi noapm noscsi frugal dma toram mydsl=hda5 restore=hda5 host=DSL1 secure

title DSL with XFree86
kernel /boot/linux24 root=/dev/hda5 quiet vga=normal noacpi noapm noscsi frugal dma toram mydsl=hda5/xfree restore=hda6 host=DSL1 secure

title DSL with mydsl,
restore, persistentancy, hostname, and passwords

kernel /boot/linux24 root=/dev/hda5 quiet vga=normal noacpi noapm noscsi frugal dma toram mydsl=hda3 restore=hda3 home=hda3 opt=hda3 host=DSL1 secure

title DSL Runlevel 2
kernel /boot/linux24 root=/dev/hda5 quiet vga=normal noacpi noapm noscsi nodma frugal 2 base norestore

#title DSL Check filesystem(s)
kernel /boot/linux24 root=/dev/hda5 quiet vga=normal noacpi noapm noscsi nodma frugal 2 base norestore legacy checkfs

We will modify the file in this way:
– we type the character ‘#’ on the beginning of the line with “defaul 0”
– under “title dsl” we have to add the command “root (hd0,X)” where X is the number who we find substracting the number of hdaY y-1=x Y is the value that Linux uses to identify the partition where is installed, but GRUB subtracting 1 to this value, for example a partition as hda7 for GRUB will be (hd0,6).
– we can comment out the line of other starting commands of DSL typing the character “#” at the beginning of each line
– for running Windows 98 we must add this instructions:

title Windows 98
hide (hd0,0)
hide (hd0,1)
unhide (hd0,2)
rootnoverify (hd0,2)
chainloader +1
makeactive

Your menu.lst should looks like this:

# This sets the default entry to boot.
# Remember that GRUB counts from 0, so 1 is the second entry.
#default 0
# This sets the length of time in seconds that grub will wait for the user to select an OS
# before it boots the default on.
I reccommend at least 15 seconds.
timeout 15
#Enter the entry for DSL here. Something like this.

title DSL
root (hd0,4)

kernel /boot/linux24 root=/dev/hda5 quiet vga=normal noacpi noapm nodma noscsi frugal

#title DSL fb800x600
#kernel /boot/linux24 root=/dev/hda5 quiet vga=788 noacpi noapm nodma noscsi frugal

#title DSL fb1024x768
#kernel /boot/linux24 root=/dev/hda5 quiet vga=791 noacpi noapm nodma noscsi frugal

#title DSL fb1280x1024
#kernel /boot/linux24 root=/dev/hda5 quiet vga=794 noacpi noapm nodma noscsi frugal

#title DSL with toram, mydsl, restore, hostname, and passwords
#kernel /boot/linux24 root=/dev/hda5 quiet vga=normal noacpi noapm noscsi frugal dma toram mydsl=hda5 restore=hda5 host=DSL1 secure

#title DSL with XFree86
#kernel /boot/linux24 root=/dev/hda5 quiet vga=normal noacpi noapm noscsi frugal dma toram mydsl=hda5/xfree restore=hda6 host=DSL1 secure

#title DSL with mydsl, restore, persistentancy, hostname, and passwords
#kernel /boot/linux24 root=/dev/hda5 quiet vga=normal noacpi noapm noscsi frugal dma toram mydsl=hda3 restore=hda3 home=hda3 opt=hda3 host=DSL1 secure

#title DSL Runlevel 2
#kernel /boot/linux24 root=/dev/hda5 quiet vga=normal noacpi noapm noscsi nodma frugal 2 base norestore

#title DSL Check filesystem(s)
#kernel /boot/linux24 root=/dev/hda5 quiet vga=normal noacpi noapm noscsi nodma frugal 2 base norestore legacy checkfs

title Windows 98
hide (hd0,0)
hide (hd0,1)
unhide (hd0,2)
rootnoverify (hd0,2)
chainloader +1
makeactive

title Partition 2(floppy)
hide (hd0,0)
unhide (hd0,1)
hide (hd0,2)
chainloader (fd0) +1

title Partition 3(floppy)
hide (hd0,0)
hide (hd0,1)
unhide (hd0,2)
chainloader (fd0) +1

Save the file, if you are working on Linux waiting one minute for the sync. Reboot the pc with the floppy and enjoy your DSL Linux. If you have some trouble to make the floppy you can use the floppy image that i have created.

[Download] This file zip contain:
-bootlinux.img (file for booting a cd-rom of linux on old pc which don’t have the boot of cd-rom)
-floppy image.exe (program to write the img file)
-grub091dsl.img (the floppy image i have created)
-recoveryPM8_disk_1.img
-recoveryPM8_disk_2.img (emergency disk of partition magic, useful to create partition on DOS)
-win95bootfloppy.img (bootable floppy of Windows 95 with optical support for cd-rom, mscdex.exe)

Remove the updating advertisement of Avira AntiVir 8/9/10 *

Guide for Windows 7

Now i will show you the simplest way to block avnotify.exe. This metod avoid the annoyance message “The size of the file AVNOTIFY.EXE has been modified! …ect”.

The tool gpedit.msc is present in Ultimate/Professional/Enterprise Windows versions only. If you have other versions, I am sorry, i have no solutions for you.

Start > gpedit.msc (WINDOWS KEY + E, digit “gpedit.msc”)

Go into the folder “Computer Configuration > Windows Settings > Security Settings > Software Restriction Policies”.

Right click on “Software Restriction Policies”, choose the menu’s voice “New Software Restriction Policies”, in this way we active the security policies’s Windows.

After the activation of the policies it will appears two sub-directory. Go under sub-directory called “Additional Rules”. Right click in the blank area and choose voice’s menu “New Path Rule…”.

Search the file avnotify.exe in installation’s directory of Antivir, usually it’s

C:\Program Files\Avira\AntiVir Desktop\avnotify.exe

End! Enjoy your Avira Antivir! And use No Notify Avira to remove the startup splash screen of Antivir, it will increase you computer boot-speed.