···8181 '')
8282 (mkRemovedOptionModule ["services" "wakeonlan"] "This module was removed in favor of enabling it with networking.interfaces.<name>.wakeOnLan")
83838484+ (mkRemovedOptionModule [ "services" "kippo" ] "The corresponding package was removed from nixpkgs.")
8585+8486 # Do NOT add any option renames here, see top of the file
8587 ];
8688}
-117
nixos/modules/services/networking/kippo.nix
···11-# NixOS module for kippo honeypot ssh server
22-# See all the options for configuration details.
33-#
44-# Default port is 2222. Recommend using something like this for port redirection to default SSH port:
55-# networking.firewall.extraCommands = ''
66-# iptables -t nat -A PREROUTING -i IN_IFACE -p tcp --dport 22 -j REDIRECT --to-port 2222'';
77-#
88-# Lastly: use this service at your own risk. I am working on a way to run this inside a VM.
99-{ config, lib, pkgs, ... }:
1010-with lib;
1111-let
1212- cfg = config.services.kippo;
1313-in
1414-{
1515- options = {
1616- services.kippo = {
1717- enable = mkOption {
1818- default = false;
1919- type = types.bool;
2020- description = "Enable the kippo honeypot ssh server.";
2121- };
2222- port = mkOption {
2323- default = 2222;
2424- type = types.int;
2525- description = "TCP port number for kippo to bind to.";
2626- };
2727- hostname = mkOption {
2828- default = "nas3";
2929- type = types.str;
3030- description = "Hostname for kippo to present to SSH login";
3131- };
3232- varPath = mkOption {
3333- default = "/var/lib/kippo";
3434- type = types.path;
3535- description = "Path of read/write files needed for operation and configuration.";
3636- };
3737- logPath = mkOption {
3838- default = "/var/log/kippo";
3939- type = types.path;
4040- description = "Path of log files needed for operation and configuration.";
4141- };
4242- pidPath = mkOption {
4343- default = "/run/kippo";
4444- type = types.path;
4545- description = "Path of pid files needed for operation.";
4646- };
4747- extraConfig = mkOption {
4848- default = "";
4949- type = types.lines;
5050- description = "Extra verbatim configuration added to the end of kippo.cfg.";
5151- };
5252- };
5353-5454- };
5555- config = mkIf cfg.enable {
5656- environment.systemPackages = with pkgs.pythonPackages; [
5757- python pkgs.kippo.twisted pycrypto pyasn1 ];
5858-5959- environment.etc."kippo.cfg".text = ''
6060- # Automatically generated by NixOS.
6161- # See ${pkgs.kippo}/src/kippo.cfg for details.
6262- [honeypot]
6363- log_path = ${cfg.logPath}
6464- download_path = ${cfg.logPath}/dl
6565- filesystem_file = ${cfg.varPath}/honeyfs
6666- filesystem_file = ${cfg.varPath}/fs.pickle
6767- data_path = ${cfg.varPath}/data
6868- txtcmds_path = ${cfg.varPath}/txtcmds
6969- public_key = ${cfg.varPath}/keys/public.key
7070- private_key = ${cfg.varPath}/keys/private.key
7171- ssh_port = ${toString cfg.port}
7272- hostname = ${cfg.hostname}
7373- ${cfg.extraConfig}
7474- '';
7575-7676- users.users.kippo = {
7777- description = "kippo web server privilege separation user";
7878- uid = 108; # why does config.ids.uids.kippo give an error?
7979- };
8080- users.groups.kippo.gid = 108;
8181-8282- systemd.services.kippo = with pkgs; {
8383- description = "Kippo Web Server";
8484- after = [ "network.target" ];
8585- wantedBy = [ "multi-user.target" ];
8686- environment.PYTHONPATH = "${pkgs.kippo}/src/:${pkgs.pythonPackages.pycrypto}/lib/python2.7/site-packages/:${pkgs.pythonPackages.pyasn1}/lib/python2.7/site-packages/:${pkgs.pythonPackages.python}/lib/python2.7/site-packages/:${pkgs.kippo.twisted}/lib/python2.7/site-packages/:.";
8787- preStart = ''
8888- if [ ! -d ${cfg.varPath}/ ] ; then
8989- mkdir -p ${cfg.logPath}/tty
9090- mkdir -p ${cfg.logPath}/dl
9191- mkdir -p ${cfg.varPath}/keys
9292- cp ${pkgs.kippo}/src/honeyfs ${cfg.varPath} -r
9393- cp ${pkgs.kippo}/src/fs.pickle ${cfg.varPath}/fs.pickle
9494- cp ${pkgs.kippo}/src/data ${cfg.varPath} -r
9595- cp ${pkgs.kippo}/src/txtcmds ${cfg.varPath} -r
9696-9797- chmod u+rw ${cfg.varPath} -R
9898- chown kippo.kippo ${cfg.varPath} -R
9999- chown kippo.kippo ${cfg.logPath} -R
100100- chmod u+rw ${cfg.logPath} -R
101101- fi
102102- if [ ! -d ${cfg.pidPath}/ ] ; then
103103- mkdir -p ${cfg.pidPath}
104104- chmod u+rw ${cfg.pidPath}
105105- chown kippo.kippo ${cfg.pidPath}
106106- fi
107107- '';
108108-109109- serviceConfig.ExecStart = "${pkgs.kippo.twisted}/bin/twistd -y ${pkgs.kippo}/src/kippo.tac --syslog --rundir=${cfg.varPath}/ --pidfile=${cfg.pidPath}/kippo.pid --prefix=kippo -n";
110110- serviceConfig.PermissionsStartOnly = true;
111111- serviceConfig.User = "kippo";
112112- serviceConfig.Group = "kippo";
113113- };
114114-};
115115-}
116116-117117-