- Feb 23, 2020
-
-
Simon Tatham authored
This is built more or less entirely out of pieces I already had. The SOCKS server code is provided by the dynamic forwarding code in portfwd.c. When that accepts a connection request, it wants to talk to an SSH ConnectionLayer, which is already a trait with interchangeable implementations - so I just provide one of my own which only supports the lportfwd_open() method. And that in turn returns an SshChannel object, with a special trait implementation all of whose methods just funnel back to an ordinary Socket. Result: you get a Socket-to-Socket SOCKS implementation with no SSH anywhere, and even a minimal amount of need to _pretend_ internally to be an SSH implementation. Additional features include the ability to log all the traffic in the form of diagnostics to standard error, or log each direction of each connection separately to a file, or for anything more general, to log each direction of each connection through a pipe to a subcommand that can filter out whatever you think are the interesting parts. Also, you can spawn a subcommand after the SOCKS server is set up, and terminate automatically when that subcommand does - e.g. you might use this to wrap the execution of a single SOCKS-using program. This is a modernisation of a diagnostic utility I've had kicking around out-of-tree for a long time. With all of last year's refactorings, it now becomes feasible to keep it in-tree without needing huge amounts of scaffolding. Also, this version runs on Windows, which is more than the old one did. (On Windows I haven't implemented the subprocess parts, although there's no reason I _couldn't_.) As well as diagnostic uses, this may also be useful in some situations as a thing to forward ports to: PuTTY doesn't currently support reverse dynamic port forwarding (in which the remote listening port acts as a SOCKS server), but you could get the same effect by forwarding a remote port to a local instance of this. (Although, of course, that's nothing you couldn't achieve using any other SOCKS server.)
-
- Feb 22, 2020
-
-
Simon Tatham authored
In the previous commit I introduced the ability for PuTTY to talk to a server speaking the bare ssh-connection protocol, and listed several applications for that ability. But none of those applications is any use without a server that speaks the same protocol. Until now, the only such server has been the Unix-domain socket presented by an upstream connection-sharing PuTTY - and we already had a way to connect to that. So here's the missing piece: by reusing code that already existed for the testing SSH server Uppity, I've created a program that will speak the bare ssh-connection protocol on its standard I/O channels. If you want to get a shell session over any of the transports I mentioned in the last commit, this is the program you need to run at the far end of it. I have yet to write the documentation, but just in case I forget, the name stands for 'Pseudo Ssh for Untappable, Separately Authenticated Networks'.
-
- Feb 20, 2019
-
-
Simon Tatham authored
This is for sanitising output that's going to be sent to a terminal, if you don't want it to be able to send arbitrary escape sequences and thereby (for example) move the cursor back up to existing text on the screen and overprint it confusingly. It works using the standard C library: we convert to a wide-character string and back, and then use wctype.h to spot control characters in the intermediate form. This means its idea of the conversion character set is locale-based rather than any of our own charset library's fixed settings - which is what you want if the aim is to protect your local terminal (which we assume the system locale represents accurately). This also means that the sanitiser strips things that will _act_ as control characters when sent to the local terminal, whether or not they were intended as control characters by a server that might have had a different character set in mind. Since the main aim is to protect the local terminal rather than to faithfully replicate the server's intention, I think that's the right criterion. It only strips control characters at the charset-independent layer, like backspace, carriage return and the escape character: wctype.h classifies those as control characters, but classifies as printing all of the more Unicode-specific controls like bidirectional overrides. But that's enough to prevent cursor repositioning, for example. stripctrl.c comes with a test main() of its own, which I wasn't able to fold into testcrypt and put in the test suite because of its dependence on the system locale - it wouldn't be guaranteed to work the same way on different test systems anyway. A knock-on build tweak: because you can feed data into this sanitiser in chunks of arbitrary size, including partial multibyte chars, I had to use mbrtowc() for the decoding, and that means that in the 'old' Win32 builds I have to link against the Visual Studio C++ library as well as the C library, because for some reason that's where mbrtowc lived in VS2003.
-
- Feb 10, 2019
-
-
Simon Tatham authored
All the work I've put in in the last few months to eliminate timing and cache side channels from PuTTY's mp_int and cipher implementations has been on a seat-of-the-pants basis: just thinking very hard about what kinds of language construction I think would be safe to use, and trying not to absentmindedly leave a conditional branch or a cast to bool somewhere vital. Now I've got a test suite! The basic idea is that you run the same crypto primitive multiple times, with inputs differing only in ways that are supposed to avoid being leaked by timing or leaving evidence in the cache; then you instrument the code so that it logs all the control flow, memory access and a couple of other relevant things in each of those runs, and finally, compare the logs and expect them to be identical. The instrumentation is done using DynamoRIO, which I found to be well suited to this kind of work: it lets you define custom modifications of the code in a reasonably low-effort way, and it lets you work at both the low level of examining single instructions _and_ the higher level of the function call ABI (so you can give things like malloc special treatment, not to mention intercepting communications from the program being instrumented). Build instructions are all in the comment at the top of testsc.c. At present, I've found this test to give a 100% pass rate using gcc -O0 and -O3 (Ubuntu 18.10). With clang, there are a couple of failures, which I'll fix in the next commit.
-
- Feb 09, 2019
-
-
Simon Tatham authored
I don't know why this sometimes gets created, but it's clearly the kind of thing that belongs in .gitignore if it exists at all.
-
- Jan 07, 2019
-
-
Simon Tatham authored
This should have been done months ago in commit bf0cf984, but I've been indecisive about whether to keep my local dev builds in the windows subdirectory itself or one level further down...
-
- Jan 03, 2019
-
-
Simon Tatham authored
I've written a new standalone test program which incorporates all of PuTTY's crypto code, including the mp_int and low-level elliptic curve layers but also going all the way up to the implementations of the MAC, hash, cipher, public key and kex abstractions. The test program itself, 'testcrypt', speaks a simple line-oriented protocol on standard I/O in which you write the name of a function call followed by some inputs, and it gives you back a list of outputs preceded by a line telling you how many there are. Dynamically allocated objects are assigned string ids in the protocol, and there's a 'free' function that tells testcrypt when it can dispose of one. It's possible to speak that protocol by hand, but cumbersome. I've also provided a Python module that wraps it, by running testcrypt as a persistent subprocess and gatewaying all the function calls into things that look reasonably natural to call from Python. The Python module and testcrypt.c both read a carefully formatted header file testcrypt.h which contains the name and signature of every exported function, so it costs minimal effort to expose a given function through this test API. In a few cases it's necessary to write a wrapper in testcrypt.c that makes the function look more friendly, but mostly you don't even need that. (Though that is one of the motivations between a lot of API cleanups I've done recently!) I considered doing Python integration in the more obvious way, by linking parts of the PuTTY code directly into a native-code .so Python module. I decided against it because this way is more flexible: I can run the testcrypt program on its own, or compile it in a way that Python wouldn't play nicely with (I bet compiling just that .so with Leak Sanitiser wouldn't do what you wanted when Python loaded it!), or attach a debugger to it. I can even recompile testcrypt for a different CPU architecture (32- vs 64-bit, or even running it on a different machine over ssh or under emulation) and still layer the nice API on top of that via the local Python interpreter. All I need is a bidirectional data channel.
-
Simon Tatham authored
These should have gone out when the old bignums and their testing system went away.
-
- Nov 27, 2018
-
-
Simon Tatham authored
Now, instead of getting the zlib test/helper program by manually compiling a source file with unusual options, it gets built as standard by the ordinary Makefile.
-
- Oct 21, 2018
-
-
Simon Tatham authored
This server is NOT SECURE! If anyone is reading this commit message, DO NOT DEPLOY IT IN A HOSTILE-FACING ENVIRONMENT! Its purpose is to speak the server end of everything PuTTY speaks on the client side, so that I can test that I haven't broken PuTTY when I reorganise its code, even things like RSA key exchange or chained auth methods which it's hard to find a server that speaks at all. (For this reason, it's declared with [UT] in the Recipe file, so that it falls into the same category as programs like testbn, which won't be installed by 'make install'.) Working title is 'Uppity', partly for 'Universal PuTTY Protocol Interaction Test Yoke', but mostly because it looks quite like the word 'PuTTY' with part of it reversed. (Apparently 'test yoke' is a very rarely used term meaning something not altogether unlike 'test harness', which is a bit of a stretch, but it'll do.) It doesn't actually _support_ everything I want yet. At the moment, it's a proof of concept only. But it has most of the machinery present, and the parts it's missing - such as chained auth methods - should be easy enough to add because I've built in the required flexibility, in the form of an AuthPolicy object which can request them if it wants to. However, the current AuthPolicy object is entirely trivial, and will let in any user with the password "weasel". (Another way in which this is not a production-ready server is that it also has no interaction with the OS's authentication system. In particular, it will not only let in any user with the same password, but it won't even change uid - it will open shells and forwardings under whatever user id you started it up as.) Currently, the program can only speak the SSH protocol on its standard I/O channels (using the new FdSocket facility), so if you want it to listen on a network port, you'll have to run it from some kind of separate listening program similar to inetd. For my own tests, I'm not even doing that: I'm just having PuTTY spawn it as a local proxy process, which also conveniently eliminates the risk of anyone hostile connecting to it. The bulk of the actual code reorganisation is already done by previous commits, so this change is _mostly_ just dropping in a new set of server-specific source files alongside the client-specific ones I created recently. The remaining changes in the shared SSH code are numerous, but all minor: - a few extra parameters to BPP and PPL constructors (e.g. 'are you in server mode?'), and pass both sets of SSH-1 protocol flags from the login to the connection layer - in server mode, unconditionally send our version string _before_ waiting for the remote one - a new hook in the SSH-1 BPP to handle enabling compression in server mode, where the message exchange works the other way round - new code in the SSH-2 BPP to do _deferred_ compression the other way round (the non-deferred version is still nicely symmetric) - in the SSH-2 transport layer, some adjustments to do key derivation either way round (swapping round the identifying letters in the various hash preimages, and making sure to list the KEXINITs in the right order) - also in the SSH-2 transport layer, an if statement that controls whether we send SERVICE_REQUEST and wait for SERVICE_ACCEPT, or vice versa - new ConnectionLayer methods for opening outgoing channels for X and agent forwardings - new functions in portfwd.c to establish listening sockets suitable for remote-to-local port forwarding (i.e. not under the direction of a Conf the way it's done on the client side).
-
- Sep 13, 2017
-
-
Simon Tatham authored
After a conversation this week with a user who tried to use it, it's clear that Borland C can't build the up-to-date PuTTY without having to make too many compromises of functionality (unsupported API details, no 'long long' type), even above the issues that could be worked round with extra porting ifdefs.
-
- Feb 05, 2017
-
-
Simon Tatham authored
This was very strange to write, because it's a bizarre combination of the GNU-make-isms and rc commands of Makefile.mgw with the cl and link commands of Makefile.vc (but also the latter thankfully doesn't need those horrible response files). I've added a big comment in mkfiles.pl about what the build requirements for this makefile actually are, which _hopefully_ will be usable by people other than me.
-
- Apr 10, 2016
-
-
Jacob Nevins authored
It's really only useful with MinGW rather than a Cygwin toolchain these days, as recent versions of the latter insist against linking with the Cygwin DLL. (I think it may no longer be possible to build with Cygwin out of the box at all these days, but I'm not going to say so without having actually checked that's the case. Settle for listing MinGW first in various comments and docs.)
-
- Mar 30, 2016
-
-
Simon Tatham authored
cmdgen.c has contained code for ages to build a test main() if you compile with -DTEST_CMDGEN. But it's painful to do so manually, since you've still got to link in all the same supporting objects, and also nobody can have actually done that for a while because the stub test code hasn't been kept up to date with changes in the internal APIs (specifically prompt_t). Now we have the ability to include our test programs in Recipe as [UT] or [XT] so as to leave them out of 'make install', that seems like a useful thing to do with cmdgen's test suite. So here's a Recipe change that builds it as 'cgtest', plus fixes for compiler warnings and bit rot. Pleasantly, the test suite still _passes_ after those are fixed.
-
- Mar 25, 2016
-
-
Simon Tatham authored
The current state of the OS X GTK port is looking more or less plausible - it's not finished, of course, but then neither was the old native Cocoa port. So I'm inclined to advertise it as *the* unfinished OS X port: it's the one I intend to keep working on, and it's the one I'd prefer people offered us help with if they're going to offer. Hence, leaving the old macosx directory around is just confusing; that directory is long-unmaintained, probably doesn't even compile, and its only effect will be to mislead people into thinking it's still relevant. I'm unilaterally deleting it; of course we can always recover it from source control history if it's ever necessary to do so.
-
- Mar 23, 2016
-
-
Simon Tatham authored
This is a file that generally seems to turn up when you start using OS X Finder to interact with directories - which is more likely now that we're building OS X app bundles into this source tree.
-
Simon Tatham authored
This commit adds two .plist files, which go in the app bundles; two .bundle files, which are input to gtk-mac-bundler and explain to it how to _create_ the bundles; and a piece of manual addition to Makefile.am that actually runs gtk-mac-bundler after building the gtkapp.c based binaries and the OSX launcher. The latter is conditionalised on configuring --with-quartz (unlike the binaries themselves, which you can build on other platforms too, though they won't do much that's useful).
-
Simon Tatham authored
The big problem with making an OS X application out of a GTK program is that it won't start unless DYLD_LIBRARY_PATH and several other environment variables point at all the GTK machinery. So your app bundle has to contain two programs: a launcher to set up that environment, and then the real main program that the launcher execs once it's done so. But in our case, we also need pterm to start subprocesses _without_ all that stuff in the environment - so our launcher has to be more complicated than the usual one, because it's also got to save every detail of how the environment was when it started up. So this is the launcher program I'm going to use. Comments in the header explain in more detail how it'll work. Also in this commit, I add the other end of the same machinery to gtkapp.c and uxpty.c: the former catches an extra command-line argument that the launcher used to indicate how it had munged the environment, and stores it in a global variable where the latter can pick it up after fork() and use to actually undo the munging.
-
Simon Tatham authored
When it's finished, this will be the backbone of the OS X GTK port: using a GtkApplication automatically gives us a properly OS X integrated menu bar. Using this source file in place of gtkmain.c turns the usual Unix single-session-per-process PuTTY or pterm into the multi-session-per- process OS X style one. Things like Duplicate Session can be done much more simply here - we just grab the Conf * from the source window and launch a new window using it, with no fiddly interprocess work needed. This is still experimental and has a lot of holes, but it's usable enough to test and improve.
-
Simon Tatham authored
mkicon.py now outputs .pam by hand, rather than using ImageMagick to go straight to .png. For most purposes the main makefile then uses ImageMagick anyway, to convert those .pams straight to the .pngs that the rest of the scripts were expecting. But one script that doesn't do that is macicon.py, which builds the MacOS .icns file by directly reading those .pam files back in. This allows the 'make icns' target in the icons directory to build from a clean checkout on vanilla MacOS, without requiring a user to install ImageMagick or any other non-core Python image handling module. (I could probably take this change at least a little bit further. I don't see any reason why icon.pl - generating the Windows .ico files - couldn't read the .pam files directly, about as easily as macicon.py did, if anyone had a use case for building the Windows icons in the presence of Python and Perl but in the absence of ImageMagick. But the .png files are directly useful outputs for Unix, so _some_ PNG-writing will have to remain here.)
-
- Mar 21, 2016
-
-
Simon Tatham authored
-
- Feb 29, 2016
-
-
Simon Tatham authored
Arrgh, _another_ one I only remember seconds too late! (cherry picked from commit 51465fac)
-
Simon Tatham authored
Now we have licence.pl, it seems to me to make very good sense to have it generate the Halibut form(s) of the licence and copyright year as well as the source-code forms. As a result, I believe _no_ copies of the licence text or copyright date exist any more except for the master one in LICENCE - so I can completely remove the checklist section about all the places to update it, because there's only one. Hooray! (cherry picked from commit 774d37a0) Conflicts: doc/licence.but (cherry-picker's note: the conflict was just because the deleted file didn't have identical contents)
-
Simon Tatham authored
Now all the uses of the licence text or the short copyright notice get it from a new header "licence.h", which in turn is built by a Perl script licence.pl invoked by mkfiles.pl, using LICENCE itself as the source. Hence, I can completely remove a whole section from the list of licence locations in CHECKLST.txt :-) (cherry picked from commit 9ddd071e) Conflicts: unix/gtkdlg.c windows/winpgnt.c (cherry-picker's notes: one conflict was just changed context, the other was deleting a copy of the licence that wasn't quite the same between branches)
-
- Dec 22, 2015
-
-
Simon Tatham authored
Arrgh, _another_ one I only remember seconds too late!
-
Simon Tatham authored
Now we have licence.pl, it seems to me to make very good sense to have it generate the Halibut form(s) of the licence and copyright year as well as the source-code forms. As a result, I believe _no_ copies of the licence text or copyright date exist any more except for the master one in LICENCE - so I can completely remove the checklist section about all the places to update it, because there's only one. Hooray!
-
Simon Tatham authored
Now all the uses of the licence text or the short copyright notice get it from a new header "licence.h", which in turn is built by a Perl script licence.pl invoked by mkfiles.pl, using LICENCE itself as the source. Hence, I can completely remove a whole section from the list of licence locations in CHECKLST.txt :-)
-
Simon Tatham authored
One of these days I'll think of a way of not forgetting this every time...
-
- Nov 08, 2015
-
-
Jacob Nevins authored
-
- Sep 06, 2015
-
-
Simon Tatham authored
The Xcode icon composer doesn't seem to exist any more in modern versions of Xcode, or at least if it does then it's well hidden and certainly doesn't live at the top-level path at /Developer where web pages still claim it can be found. There is a free software 'libicns' and associated command-line tools, but they're large, complicated, picky about the exact format of PNGs they get as input, and in any case a needless extra build dependency when it turns out the important parts of the file format can be done in a few dozen lines of Python. So here's a new macicon.py, and icons/Makefile additions to build a demo icon for OS X PuTTY, as and when I finally get it working. Also I've deleted the static icon file in the neglected 'macosx' source directory, because this one is better anyway - the old one was appalling quality, and must have been autogenerated from a single image in some way.
-
- Jun 20, 2015
-
-
Simon Tatham authored
encodelib.py is a Python library which implements some handy SSH-2 encoding primitives; samplekex.py uses that to fabricate the start of an SSH connection, up to the point where key exchange totally fails its crypto. The idea is that you adapt samplekex.py to construct initial-kex sequences with particular properties, in order to test robustness and security fixes that affect the initial-kex sequence. For example, I used an adaptation of this to test the Diffie-Hellman range check that's just gone into 0.64. (cherry picked from commit 12d5b00d)
-
- Feb 28, 2015
-
-
Simon Tatham authored
encodelib.py is a Python library which implements some handy SSH-2 encoding primitives; samplekex.py uses that to fabricate the start of an SSH connection, up to the point where key exchange totally fails its crypto. The idea is that you adapt samplekex.py to construct initial-kex sequences with particular properties, in order to test robustness and security fixes that affect the initial-kex sequence. For example, I used an adaptation of this to test the Diffie-Hellman range check that's just gone into 0.64.
-
- Oct 25, 2014
-
-
Simon Tatham authored
-