From 8baff31b51b03dc0301a559b869b8678af5cb593 Mon Sep 17 00:00:00 2001 From: jdh8d <jdh8d@git.zephyr-software.com> Date: Fri, 9 Feb 2018 20:11:59 +0000 Subject: [PATCH] revised to release to ais w/o ida.key, added installer and test harness for ubuntu16 --- .gitattributes | 7 +++ manifest.txt | 3 ++ postgres_setup.sh | 32 +++++++------ regen_install.sh | 20 +++++++++ set_env_vars | 4 +- ubuntu16_files/README.txt | 27 +++++++++++ ubuntu16_files/Vagrantfile | 57 ++++++++++++++++++++++++ ubuntu16_files/generate_ais_installer.sh | 8 ++++ ubuntu16_files/install.sh | 27 +++++++++++ ubuntu16_files/manifest.txt | 3 ++ ubuntu16_files/test.sh | 5 +++ 11 files changed, 177 insertions(+), 16 deletions(-) create mode 100755 regen_install.sh create mode 100644 ubuntu16_files/README.txt create mode 100644 ubuntu16_files/Vagrantfile create mode 100644 ubuntu16_files/generate_ais_installer.sh create mode 100755 ubuntu16_files/install.sh create mode 100644 ubuntu16_files/manifest.txt create mode 100644 ubuntu16_files/test.sh diff --git a/.gitattributes b/.gitattributes index 06799001b..ce9cded84 100644 --- a/.gitattributes +++ b/.gitattributes @@ -64,9 +64,16 @@ centos_files/zlib-1.2.7-17.el7.x86_64.rpm -text svneol=unset#application/x-rpm /irdb_vars -text /manifest.txt -text /postgres_setup.sh -text +/regen_install.sh -text /set_command_envs -text /set_env_vars -text /set_ida_server -text /start_dev.sh -text /svn.externals.uva_dev -text +ubuntu16_files/README.txt -text +ubuntu16_files/Vagrantfile -text +ubuntu16_files/generate_ais_installer.sh -text +ubuntu16_files/install.sh -text +ubuntu16_files/manifest.txt -text +ubuntu16_files/test.sh -text /yum_packages.sh -text diff --git a/manifest.txt b/manifest.txt index 3cd1f0fea..77ba7587b 100644 --- a/manifest.txt +++ b/manifest.txt @@ -6,9 +6,12 @@ submanifest SMPStaticAnalyzer/manifest.txt submanifest zipr_install/manifest.txt submanifest stratafier/manifest.txt submanifest IdaProServer/manifest.txt +submanifest ubuntu16_files/manifest.txt file set_command_envs ps file set_env_vars ps file set_ida_server ps file irdb_vars ps file yum_packages.sh centos +file postgres_setup.sh ps +file README.txt ps directory centos_files centos diff --git a/postgres_setup.sh b/postgres_setup.sh index efbc65e46..ad2710d60 100755 --- a/postgres_setup.sh +++ b/postgres_setup.sh @@ -1,20 +1,24 @@ #!/bin/bash -#Add PostGres password file for modifying the database -printf ":5432::$USER:1qaz2wsx\nlocalhost:5432:*:$USER:1qaz2wsx\n127.0.0.1:5432:*:$USER:1qaz2wsx" > $HOME/.pgpass -chmod og-rw $HOME/.pgpass -#Allow remote access to PostGres -sudo su -c "printf \"\nhost \t all \t all \t 127.0.0.1/16 \t md5\nhostssl all \t all \t 127.0.0.1/16 \t md5\n\" >> /etc/postgresql/9.3/main/pg_hba.conf" -printf "\nlisten_addresses = '*'\n" | sudo tee -a /etc/postgresql/9.3/main/postgresql.conf > /dev/null +main() +{ + local randpass=$(date +%s | sha256sum | base64 | head -c 32) -#Restart PostGres -sudo service postgresql restart + #Add PostGres password file for modifying the database + newlines=$(printf ":5432::$USER:$randpass\nlocalhost:5432:*:$USER:$randpass\n127.0.0.1:5432:*:$USER:$randpass\n" ) + echo -e "$newlines$(cat $HOME/.pgpass >/dev/null)" > $HOME/.pgpass + chmod og-rw $HOME/.pgpass -#Create Database User and Table -echo "CREATE ROLE $USER WITH CREATEDB LOGIN NOSUPERUSER NOCREATEROLE PASSWORD '1qaz2wsx'" | sudo -u postgres psql -sudo su -c "createdb -O $USER peasoup_$USER" postgres + #Create Database User and Table + echo "CREATE ROLE $USER WITH CREATEDB LOGIN NOSUPERUSER NOCREATEROLE PASSWORD '$randpass'" | sudo -u postgres psql + echo "ALTER ROLE $USER WITH PASSWORD '$randpass'" | sudo -u postgres psql + dropdb peasoup_$USER + createdb peasoup_$USER -#Setup the Database to store PEASOUP info -source set_env_vars -$PEASOUP_HOME/tools/db/pdb_setup.sh + #Setup the Database to store PEASOUP info + source set_env_vars + $PEASOUP_HOME/tools/db/pdb_setup.sh +} + +main diff --git a/regen_install.sh b/regen_install.sh new file mode 100755 index 000000000..120a59808 --- /dev/null +++ b/regen_install.sh @@ -0,0 +1,20 @@ +#!/bin/bash + + +main() +{ + local keys="$@" + + local key_args="" + for i in $keys + do + key_args="$key_args -l $i" + done + + $PEDI_HOME/pedi --clean -m manifest.txt + $PEDI_HOME/pedi --setup -m manifest.txt $key_args -i $PS_INSTALL + $PEDI_HOME/pedi -m manifest.txt + +} + +main "$@" diff --git a/set_env_vars b/set_env_vars index ff1dbc12b..34ce0fc4b 100644 --- a/set_env_vars +++ b/set_env_vars @@ -23,8 +23,8 @@ export IRDB_TRANSFORMS=$PEASOUP_UMBRELLA_DIR/irdb_transforms export ZEST_RUNTIME=$PEASOUP_UMBRELLA_DIR/zest_runtime export DAFFY_HOME=$PEASOUP_UMBRELLA_DIR/daffy -if [ -z "$PS_INSTALL" -o -f manifest.txt ]; then - if [ -z $PS_INSTALL ]; then +if [ -f manifest.txt ]; then + if [ -f $PS_INSTALL ]; then export PS_INSTALL=$PEASOUP_UMBRELLA_DIR/installed fi export PS=$PS_INSTALL/peasoup_examples/tools/ps_analyze.sh diff --git a/ubuntu16_files/README.txt b/ubuntu16_files/README.txt new file mode 100644 index 000000000..4b2121b73 --- /dev/null +++ b/ubuntu16_files/README.txt @@ -0,0 +1,27 @@ + +Steps to installing. + + 0) Unpack the tarball (likely called zipr_toolchain.tgz) -- you must have done this already + to be reading this! + 1) Switch to the directory created during unpacking. i.e., cd zipr_toolchain + 2) Copy your ida.key for IdaPro7.0 to ./idaproCur/ida.key + 3) Run "./ubuntu16_files/install.sh" in this directory -- lots of packages + will be installed. + 4) Run "source set_env_vars" + 5) This step sets up postgres to hold the Zipr database. If you already + have postgres configured, it may damage your data. Use with appropriate caution. + Run "postgres_setup.sh" + 6) Test the installation: + run "cd /tmp; $PSZ /bin/ls ./ls.ziprd" + You should see the Zipr toolchain protecting /bin/ls and writing results into the file + The Zipr toolchain should report success if installed properly. + Run the rewritten program as if it were /bin/ls: "/tmp/ls.ziprd" + + +If you log out and log back in (or log into a new session), you'll need to re-run steps 1 and 4 +before using the toolchain again. You may wish to automate this step by adding it to your .bashrc +file or other, appropriate login files. + + + + diff --git a/ubuntu16_files/Vagrantfile b/ubuntu16_files/Vagrantfile new file mode 100644 index 000000000..fb5388c22 --- /dev/null +++ b/ubuntu16_files/Vagrantfile @@ -0,0 +1,57 @@ +Vagrant.configure(2) do |config| + config.vm.define "zipr_toolchain" do |zipr_toolchain| + + # sanity check env. -- but do this after the box definition. + + zipr_toolchain.vm.box = "ubuntu/xenial64" + zipr_toolchain.vm.box_url = "http://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-vagrant.box" +# zipr_toolchain.vm.hostname = "ziprtools" + + zipr_toolchain.vm.provider "virtualbox" do |vbox| +# vbox.gui = true + vbox.name = "ziprtools" + vbox.cpus = 2 + vbox.memory = 8192 + end + + # README step 0, unpack tarball. + zipr_toolchain.vm.provision "shell", privileged: false, inline: <<-SHELL + cd /home/vagrant + tar xzf /vagrant/zipr_toolchain.tgz + SHELL + + # README step 2: install key. + zipr_toolchain.vm.provision "file", source: Pathname.new(ENV["IDAROOT"]).join("ida.key"), destination: "$HOME/zipr_toolchain/idaproCur/ida.key" + + # README step 3-6: run installer, setup postgres as vagrant, test ls. + zipr_toolchain.vm.provision "shell", privileged: false, inline: <<-SHELL + cd /home/vagrant/zipr_toolchain ; sudo ./ubuntu16_files/install.sh 2>&1 | tee /tmp/install.log + source set_env_vars + ./postgres_setup.sh + cd /tmp + $PSZ /bin/ls ./ls.protected + if ./ls.protected ; then + echo + echo + echo + echo "Installation Success! (Passed smoke test on /bin/ls)" + echo + echo + echo + else + echo + echo + echo + echo + echo "Installation failed! (Could not protect /bin/ls)" + echo + echo + echo + fi + echo "Cleaning up" + rm -Rf /tmp/ls /tmp/peasoup* + + SHELL + end +end + diff --git a/ubuntu16_files/generate_ais_installer.sh b/ubuntu16_files/generate_ais_installer.sh new file mode 100644 index 000000000..9c5406770 --- /dev/null +++ b/ubuntu16_files/generate_ais_installer.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +cd $PEASOUP_UMBRELLA_DIR + +./regen_install.sh ida ps zipr ubuntu16 stars +cp -r installed zipr_toolchain +tar czf ubuntu16_files/zipr_toolchain.tgz zipr_toolchain +rm -Rf zipr_toolchain diff --git a/ubuntu16_files/install.sh b/ubuntu16_files/install.sh new file mode 100755 index 000000000..989b8599c --- /dev/null +++ b/ubuntu16_files/install.sh @@ -0,0 +1,27 @@ +#!/bin/bash + + +main() +{ + # 1) force sudo password as necessary + # 2) make sure package manager is ready for installing packages. + sudo apt-get update + + local packages=" + realpath + gcc + nasm + coreutils + postgresql + postgresql-client + libpqxx-3.1 + python + " + + for i in $packages + do + sudo apt-get install -y $i + done +} + +main "$@" diff --git a/ubuntu16_files/manifest.txt b/ubuntu16_files/manifest.txt new file mode 100644 index 000000000..7b77a21f5 --- /dev/null +++ b/ubuntu16_files/manifest.txt @@ -0,0 +1,3 @@ + +file install.sh ubuntu16 +file README.txt ubuntu16 diff --git a/ubuntu16_files/test.sh b/ubuntu16_files/test.sh new file mode 100644 index 000000000..362dc6d3f --- /dev/null +++ b/ubuntu16_files/test.sh @@ -0,0 +1,5 @@ +#/bin/bash + +./generate_ais_installer.sh +vagrant destroy -f +vagrant up -- GitLab