etc (Use(ful/less) Stuff)

/etc

>> Escape from this.

Misc. Notes

86Box Stuff

86Box FTP

So you’re running some Win9x in 86Box and need to push or pull files from the host?

Outside of getting NetBIOS shares working, you could always just set up an FTP server.

Prerequisites

  • Python 3
  • virtualenv or venv
  • pyftpdlib
  • NIC on a 86Box guest running in SLiRP

Setup

First, we’ll set up the Python virtualenv. If you have virtualenv installed:

$ virtualenv ftp-venv
$ . ftp-venv/bin/activate
$ pip install pyftpdlib

If you have venv:

$ python3 -m venv ftp-venv
$ . ftp-venv/bin/activate
$ pip install pyftpdlib

Next, we setup our ftpd.py file. This is mostly borrowed from the pyftpdlib demos :

import os

from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

BANNER = """
    Y HELO THAR
"""

def main():
    # Instantiate a dummy authorizer for managing 'virtual' users
    authorizer = DummyAuthorizer()

    # Define a new user having full r/w permissions.
    authorizer.add_user(
        'foo',                    # username
        'bar',                    # password
        '/Users/quux/share/ftp',  # path to shared directory
        perm='elradfmwMT'         # permissions
    )

    # Instantiate FTP handler class
    handler = FTPHandler
    handler.authorizer = authorizer

    # This needs to be set to True (depending on your situation),
    # since the guest will be coming from the 10.0.x.x net.
    handler.permit_foreign_addresses = True

    # Define a customized banner (string returned when client connects)
    handler.banner = BANNER

    # Specify a masquerade address, since the host is really 10.0.2.2 to the guest.
    handler.masquerade_address = '10.0.2.2'

    # Instantiate FTP server class and listen on all interfaces, port 2121
    address = ('', 2121)
    server = FTPServer(address, handler)

    # set a limit for connections
    server.max_cons = 256
    server.max_cons_per_ip = 5

    # start ftp server
    server.serve_forever()

if __name__ == '__main__':
    main()

Make sure the shared directory path actually exists, and then just run:

$ python ftpd.py

With that running on the host side, from the 86Box guest side we can try connecting. The host will be 10.0.2.2 in this case (unless it’s not for you, see SLiRP docs for details. If it’s not, make sure to update your handler.masquerade_address in ftpd.py).