Skip to content

Commit

Permalink
first (and maybe the last) commit
Browse files Browse the repository at this point in the history
  • Loading branch information
anoopengineer committed Mar 13, 2014
0 parents commit c0c6acb
Show file tree
Hide file tree
Showing 4 changed files with 334 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
215 changes: 215 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
#################
## Eclipse
#################

*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# PDT-specific
.buildpath


#################
## Visual Studio
#################

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results

[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml
*.pubxml

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf

#############
## Windows detritus
#############

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Mac crap
.DS_Store


#############
## Python
#############

*.py[co]

# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox

#Translations
*.mo

#Mr Developer
.mr.developer.cfg
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
WinSCP Password Extractor/Decrypter/Revealer
=============================================

WinSCP stores ssh session passwords in an encrypted format in the windows registry. If you have passwords saved in WinSCP sessions but have forgotten them, use this tool to get it back.

Steps
-----
1. Open your windows registry (you can do this by hitting Win + R and entering `regedit`)
1. Navigate to [HKEY_CURRENT_USER\\Software\\Martin Prikryl\\WinSCP 2\\Sessions] to get the hostname, username and encrypted password
1. Take a command prompt and run winscppasswd passing hostname, username and encrypted password as parameter.

```sh
winscppasswd.exe <host> <username> <encrypted_password>
```
Decrypted password will be shown on the command prompt

About
------
This utility was written to "scratch my own itch" of me constantly forgetting my saved passwords. There are couple of third party tools available that can decrypt the password, but I wasn't overly joyed at the concept of handing over my password to an unkonwn tool downloaded from the internet. So I decided to write my own.

You can download a ready made binary from "Releases" section in GitHub. But you are welcome to compile the source yourself if you don't trust binary files.

This is written in Go lang. Head over to http://golang.org/ to download the compiler.
74 changes: 74 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package main

import (
"fmt"
"os"
"runtime"
"strconv"
)

const (
PW_MAGIC = 0xA3
PW_FLAG = 0xFF
)

func main() {
args := os.Args[1:]
if len(args) != 3 {
fmt.Println("WinSCP stored password finder")
fmt.Println("Open regedit and navigate to [HKEY_CURRENT_USER\\Software\\Martin Prikryl\\WinSCP 2\\Sessions] to get the hostname, username and encrypted password\n")
if runtime.GOOS == "windows" {
fmt.Println("Usage winscppasswd.exe <host> <username> <encrypted_password>")
} else {
fmt.Printf("Usage ./winscppasswd <host> <username> <encrypted_password>")
}
return
}
fmt.Println(decrypt(args[0], args[1], args[2]))
}

func decrypt(host, username, password string) string {
key := username + host
passbytes := []byte{}
for i := 0; i < len(password); i++ {
val, _ := strconv.ParseInt(string(password[i]), 16, 8)
passbytes = append(passbytes, byte(val))
}
var flag byte
flag, passbytes = dec_next_char(passbytes)
var length byte = 0
if flag == PW_FLAG {
_, passbytes = dec_next_char(passbytes)

length, passbytes = dec_next_char(passbytes)
} else {
length = flag
}
toBeDeleted, passbytes := dec_next_char(passbytes)
passbytes = passbytes[toBeDeleted*2:]

clearpass := ""
var (
i byte
val byte
)
for i = 0; i < length; i++ {
val, passbytes = dec_next_char(passbytes)
clearpass += string(val)
}

if flag == PW_FLAG {
clearpass = clearpass[len(key):]
}
return clearpass
}

func dec_next_char(passbytes []byte) (byte, []byte) {
if len(passbytes) <= 0 {
return 0, passbytes
}
a := passbytes[0]
b := passbytes[1]
passbytes = passbytes[2:]
return ^(((a << 4) + b) ^ PW_MAGIC) & 0xff, passbytes
}

0 comments on commit c0c6acb

Please sign in to comment.