Skip to content

201 Setup of the development environment for Linux and Windows

John E. Malmberg edited this page Oct 8, 2023 · 13 revisions

Introduction

Always check D-Rats README.md for the most current information.

This is a work in progress, please assist in keeping it up to date.

Development of D-Rats is Linux oriented with Microsoft Windows and Mac-OS, secondary. It should also work on any POSIX compatible plaform that has all the required libraries.

On Microsoft Windows, we are using the Linux emulation package Msys2 Mingw currently.

It should work on Cygwin, and there may be a way to get it to work on Windows Subsystem for Linux. Currently we do not have anyone testing those environments.

One obstacle for native Microsoft Windows support is that we do not have a "signed" trusted source for a pre-built GTK 3 to use with the python.org distribution for Microsoft.

There may also be commercial Python packages for some platforms that will run D-Rats, as those charge money for use on systems that could also be used for commercial work, not all of the developers we have would be able to test on them.

If someone wants to volunteer for supporting and testing what we are not yet supporting that would be great.

Old section below for now a lot is no longer applicable.

Dependency packages

There are two types of dependency packages that can be used trusted and non-trusted.

D-Rats and LZHUF are currently considered non-trusted packages. We do not have a setup for managing secure signing of packages at this time, and it does not look like anything we would be doing soon.

D-Rats must be designed so that any package that is not supplied by the currently tested operating systems or Linux emulation vendors must be optional to running D-Rats.

Trusted dependency packages

Trusted dependency packages come from an operating system vendor or a well known web site and are digitally signed with a signature that is verified by the normal installation package.

Non-trusted dependency packages

Non-trusted dependency packages are packages directly obtained from sources like GitHub, PyPi, etc. that are not digitally signed and can be uploaded by anyone.

If an attacker manages an exploit, which has happened before, where they can redirect network traffic through there own server, they can replace good packages with bad packages, and trick you into installing malware on your system, and since the signatures are not checked automatically this would not be detected.

Pip installed packages are considered non-trusted, as anyone can create a free account on PyPi to add packages, and the packages are not signed. There are a lot of counterfeit packages with similar names to legitimate packages on PyPi that will install malware, and from some reports that I have seen at the time of this writing, they are being replaced almost as fast as the PyPi maintainers find and remove them.

As such Pip packages should normally never be installed or run in a elevated privilege context.

And you have to be very careful about the pip packages that are selected for use.

PyPi packages are needed for doing some of the Python packaging operations for D-rats. We must try our best to provide configuration files that will only install legitimate packages.

To limit the potential damage that a bad Pip installed package can do, we strongly recommend using a virtual environment for both creating python packages, and when installing D-Rats using pip.

Special notes for Microsoft Windows

Microsoft Windows has several environment variables for programs like D-Rats to use, and the are generally available for the Linux emulation layer as environment variables. Some emulation layers will translate the environment variables to Posix path names, some like Msys2 will not.

Programs running under Msys2 can generally use either Microsoft Windows file paths or Linux file paths. Msys2 can use both the backslash and forward slash as a directory delimiter in a path. Generally using a backslash in a Posix environment needs it to be doubled.

A big problem that will sneak up on you in Microsoft Windows is that many of the text editing tools will save files with what is called "Windows line endings" or "carriage return/Linefeed" endings. D-Rats needs linefeeds for line endings. You have to make sure that your tools are not resulting in submitting patches with the wrong line endings.

Most modern Windows tools will properly handle text files with linefeed line endings, contrary to popular rumors.

APPDATA

This is for storing user data for an application.

This data is considered roaming, where depending on the user configuration, it may be replicated to other computers that a user uses.

APPDATA is where D-Rats looks for the D-RATS-EV directory.

For testing multiple instance of D-Rats on a Microsoft Windows computer, you need to specify an alternate configuration file.

./d-rats.py -c $APPDATA/D-RATS-test

Debugging issues that only show up on a virtual environment.

Issues show up in a virtual environment, mainly because the wrong assumptions are being made about the paths where items that need to be looked up reside.

Python 3 appears to provide some libraries for this. These may not be compatible with where D-Rats has stored those files.

Since I am using Visual Studio code, I use the command find d-rats_venv -name dplatform.py to find the directory where most of the D-Rats source is and open that folder to make debugging changes.

Previous version, much probably does not apply:


Developing on Linux

Note: the source code of d-rats is quite dated, so use python 2.7

Common libraries

  • gtk http://www.gtk.org/download/

  • gtk glade module

  • gobject

  • apt-get install:

    • python-gtk2
    • python-glade2
    • python-serial
    • python-libxml2
    • python-libxslt1
  • easy_install:

    • simplejson

    • feedparser

    • libxml2

      and also these libraries are required to export the gps positions in JSON:

    • flask

    • gevent:
      from http://www.gevent.org/ or > easy_install gevent

    • gevent-socketio > easy_install gevent-socketio

    • greenlet > easy_install gevent-socketio


Developing on Ms-Windows 10/ 7 /.../xp .. XP!!

*** Important NOTE: THE ONLY KNOWN WINDOWS INSTALLATION ABLE TO CREATE A WORKING COMPILED VERSION ON WINDOWS IS ... WINDOWS XP. THIS IS BECAUSE THE LIBRAIRES ORIGINALLY NEEDED DOES NOT WORK CORRECTLY WITH THE MORE RECENT DLLs RELATED TO NETWORK OF THE OPERATING SYSTEM ***

Note: the source code of d-rats is quite dated, so use python 2.7 compiled 32 bit and 32 bit libraries (I did a try installing the 64 bit version of python, but wasn't able to find all the libraries needed at 64 bit)

INSTALL PYTHON

INSTALL GTK2 & PYGTK

INSTALL ASPELL from http://aspell.net/win32/:
Aspell-0-50-3-3-Setup.exe - http://ftp.gnu.org/gnu/aspell/w32/Aspell-0-50-3-3-Setup.exe
Aspell-en-0.50-2-3.exe - (English) - http://ftp.gnu.org/gnu/aspell/w32/Aspell-en-0.50-2-3.exe
Aspell-it-0.50-2-3.exe - (Italian)

NOTE: In order to install the right dll for spell-checking refer to:

http://www.d-rats.com/documentation/4-howtos/34-installing-spelling-support/
(at Wayback Machine capture at: http://web.archive.org/web/20100604220003/http://www.d-rats.com/documentation/4-howtos/34-installing-spelling-support )

PYTHON LIBRARIES via installers procure and install:

PYTHON LIBRARIES via PIP INSTALL Some libraries will be installable via c:\python2.7\scripts> pip install "library-name"

--list to be completed --

PYTHON LIBRARIES via EASY INSTALL + source-code.tar.gz Some libraries need to be installed after getting the source code in tar.gz file. c:\python2.7\scripts> pip install> easy-install "path-to-source-code.tar.gz"

to compile code since from 0.3.8 install also:

  • six

SETTING THE PATH VARIABLE ON MS-WINDOWS

It seems that nasty things happen if you dont have the right order in the path variable especially if you install local Python and the various libraries, you will easily end up with a malfunctioning system.

Typical User variable path: C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon

Typical System variable path:

C:\Windows\system32;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\ThinkPad\Bluetooth Software;C:\Program Files\ThinkPad\Bluetooth Software\syswow64;C:\Program Files\Microsoft\Web Platform Installer;C:\Python27;C:\Python27\Scripts;C:\Program Files (x86)\Common Files;C:\Python27;C:\Python27\Scripts;c:\gtk\bin


COMPILING ON MS-WINDOWS XP

NOTE: D-Rats sources can be compiled on any windows platform but, when copied to other PC it will work NOT reliably with known issues related to:

  • GTK windows layout and events
  • Networking (eg. for map tiles and Ratflects connectivity )

To get a compiled version it needs to have Windows XP with a certain version of network Dlls, if updated will just not work properly.

To compile for MS Windows: launch the "distXP.bat", this will create the "dist" folder within the source code

DLLs to be removed from Dist folder These Dlls shall be deleted from the "dist" folder in order to have a working networking

  • dnsapi.dll
  • imm32.dll
  • netapi32.dll
  • ws2_32.dll
  • wsock32.dll

EXECUTE THE D-RATS APPLICATION on Windows

To execute the d-rats application:

C:\cd d-rats-source-code-folder\
C:> python d-rats.py    

Edited 20200530

Clone this wiki locally