From 6277b96b6a00465e18759f7e6cf2ded58afd4596 Mon Sep 17 00:00:00 2001 From: online-stuff Date: Wed, 21 Nov 2018 19:27:25 -0700 Subject: [PATCH 01/13] Update Dockerfile Fix cp error --- src/bitBetter/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bitBetter/Dockerfile b/src/bitBetter/Dockerfile index 8c0a695..040d604 100644 --- a/src/bitBetter/Dockerfile +++ b/src/bitBetter/Dockerfile @@ -7,7 +7,8 @@ RUN dotnet /bitBetter/bitBetter.dll && \ echo "modified dll" && \ mv /app/Core.dll /app/Core.orig.dll && \ mv /app/modified.dll /app/Core.dll && \ + mkdir /jobs && \ cp -f /app/Core.dll /jobs/Core.dll && \ echo "replaced dll" && \ rm -rf /bitBetter && rm -rf /newLicensing.cer && \ - echo "cleaned up" \ No newline at end of file + echo "cleaned up" From c6da1246ddad89502b183e8801cbbc74841458ca Mon Sep 17 00:00:00 2001 From: online-stuff Date: Wed, 21 Nov 2018 19:49:40 -0700 Subject: [PATCH 02/13] Update Program.cs --- src/licenseGen/Program.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/licenseGen/Program.cs b/src/licenseGen/Program.cs index 57e3e14..740aba9 100644 --- a/src/licenseGen/Program.cs +++ b/src/licenseGen/Program.cs @@ -165,8 +165,8 @@ namespace bitwardenSelfLicensor set("Premium", true); set("Version", 1); set("Issued", DateTime.UtcNow); - set("Refresh", DateTime.UtcNow.AddYears(1).AddMonths(-1)); - set("Expires", DateTime.UtcNow.AddYears(1)); + set("Refresh", DateTime.UtcNow.AddYears(100).AddMonths(-1)); + set("Expires", DateTime.UtcNow.AddYears(100)); set("Trial", false); set("Hash", Convert.ToBase64String((byte[])type.GetMethod("ComputeHash").Invoke(license, new object[0]))); @@ -196,7 +196,7 @@ namespace bitwardenSelfLicensor set("BillingEmail", email); set("BusinessName", "BitBetter"); set("Enabled", true); - set("Seats", (short)5); + set("Seats", (short)65534); set("MaxCollections", short.MaxValue); set("MaxStorageGb", short.MaxValue); set("SelfHost", true); @@ -207,8 +207,8 @@ namespace bitwardenSelfLicensor set("Plan", "Custom"); set("Version", 1); set("Issued", DateTime.UtcNow); - set("Refresh", DateTime.UtcNow.AddYears(1).AddMonths(-1)); - set("Expires", DateTime.UtcNow.AddYears(1)); + set("Refresh", DateTime.UtcNow.AddYears(100).AddMonths(-1)); + set("Expires", DateTime.UtcNow.AddYears(100)); set("Trial", false); set("Hash", Convert.ToBase64String((byte[])type.GetMethod("ComputeHash").Invoke(license, new object[0]))); From 1da8b95cbd52e89c3e810868f979c4091e1ea7ce Mon Sep 17 00:00:00 2001 From: online-stuff Date: Wed, 21 Nov 2018 20:17:39 -0700 Subject: [PATCH 03/13] Update Program.cs --- src/licenseGen/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/licenseGen/Program.cs b/src/licenseGen/Program.cs index 740aba9..49bab1e 100644 --- a/src/licenseGen/Program.cs +++ b/src/licenseGen/Program.cs @@ -196,7 +196,7 @@ namespace bitwardenSelfLicensor set("BillingEmail", email); set("BusinessName", "BitBetter"); set("Enabled", true); - set("Seats", (short)65534); + set("Seats", (short)32767); set("MaxCollections", short.MaxValue); set("MaxStorageGb", short.MaxValue); set("SelfHost", true); From a38ef370cb3f51bdbfc4a96fc64caaf270e46e3c Mon Sep 17 00:00:00 2001 From: online-stuff Date: Wed, 21 Nov 2018 20:42:23 -0700 Subject: [PATCH 04/13] Update Program.cs --- src/licenseGen/Program.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/licenseGen/Program.cs b/src/licenseGen/Program.cs index 49bab1e..8e0e667 100644 --- a/src/licenseGen/Program.cs +++ b/src/licenseGen/Program.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Linq; using System.Runtime.Loader; @@ -196,16 +196,19 @@ namespace bitwardenSelfLicensor set("BillingEmail", email); set("BusinessName", "BitBetter"); set("Enabled", true); + set("Plan", "Custom"); + set("PlanType", (byte)6); set("Seats", (short)32767); set("MaxCollections", short.MaxValue); - set("MaxStorageGb", short.MaxValue); - set("SelfHost", true); set("UseGroups", true); + set("UseEvents", true); set("UseDirectory", true); set("UseTotp", true); - set("PlanType", (byte)6); - set("Plan", "Custom"); - set("Version", 1); + set("Use2fa", true); + set("MaxStorageGb", short.MaxValue); + set("SelfHost", true); + set("UsersGetPremium", true); + set("Version", 4); set("Issued", DateTime.UtcNow); set("Refresh", DateTime.UtcNow.AddYears(100).AddMonths(-1)); set("Expires", DateTime.UtcNow.AddYears(100)); From f665630abdf15c3402b09272a304c3ba0664a27e Mon Sep 17 00:00:00 2001 From: online-stuff Date: Wed, 21 Nov 2018 20:59:30 -0700 Subject: [PATCH 05/13] Delete cert.cert Generate your own certificate --- .keys/cert.cert | Bin 1194 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .keys/cert.cert diff --git a/.keys/cert.cert b/.keys/cert.cert deleted file mode 100644 index 740465ba03136bd88550356c9efa1cca5a620f6a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1194 zcmV;b1XcSmf&`{8f&z{L2>`7)J#?njWSlS!1_>&LNQUlw}8?+FaSo=aOK&ww^8Nu*8UgItalZ1eyNhR#$V!-A>%kCAl;XJ$YY(!)*7= zo;!1M*TfXzEpugaqXhOL#ZLy(6Rq?`g1OQ6|t+JgD=mbM+AXiG}hu;}^ zY-lRXz)O0kU7~yn2G}kisPQbJ+bhX~#RY0XXv<%C$nY7Drz1!?{$$^H)!8pmj6v1x z^JG{``Z5yh%lxn!&pIgj*$1WyJ=dT(s|&}vpx06mrEd$KMbM@=go+CO6VN<2KuQ5l z?}^D9Syn(m@I*VGwC^Z=mV4_jtI4nS5lfPy&sRSRuw!V%Fb>hc8fP34K_m$W$9vHq zoVM_%j(r<@Nd!oPrgH!_Q0T_stR(Q4B~ED|t>_`ZKgH20)V17g1{(dpi0~dar*ZCX zwn-)-6Oyd$x7&&tx+z6^)Ur)30IHq#RV7ZR65)*nZ{SXkTgXqjh5!e25Io?Hqj#PG zA?mebMozGnKYAI1iXW>LQlLL=fbkDrNd^nOvzfw#7a0SJic2hq>tQ92C9pT-#a4I97yDRmUn>=nx6ggq{pyQuWXi5~*l>Q2j zx`=NCnH%&WHUjbsiP8m>eRa<*A%v2L^*v4#U9I?SGE4<)uYci50s{d60Wb{)2`Yw2 zhW8Bt0Sg5H1A+np04sY!VFgkPn2u(vMccurECT6KDmE4nD}Nd!o~E%PZcQ3#wDDH! zJrgR>vf_J+&VAsO0QO|TiewX2M_P`A#AuVoxW1Oxn^N<-8LDOf6%v5`)aDm`=RyPdg93A{Lm1Zs7X$?Joq{`Rl!an~*UuvI@aYWtz zv$i`pr0-^R``C!-}fl3uOv6 z?<%HDKrf~CoFj}|;=k_?DoN@b<5tlMLcnV^?C4Z@z#h8e-BWTD)F>mwg8k;j7e`|} zeF&X)Ei_RGVNy7SRzVwRxmglT@DUiIxhL&ZzGkg6l`Y-9> z_!g`k%)ovb8tfbx_kL=;NEm=M8Z4(0g1q=}`n6EgCO1EU4))qPm@h*Y!gshsYZfHY zlrrWvuMAWO2apGLmEeFoDNIb0EXkty>_qGDO{F@LpymV7?XTgsF;oGyOd3i3VF=lo I*(}b{us|yqjQ{`u From 36e8c8e51335e4e684143bf3484bab5ae73a102f Mon Sep 17 00:00:00 2001 From: online-stuff Date: Wed, 21 Nov 2018 21:03:35 -0700 Subject: [PATCH 06/13] Create touchfolder --- .keys/touchfolder | 1 + 1 file changed, 1 insertion(+) create mode 100644 .keys/touchfolder diff --git a/.keys/touchfolder b/.keys/touchfolder new file mode 100644 index 0000000..031e408 --- /dev/null +++ b/.keys/touchfolder @@ -0,0 +1 @@ +Need an empty folder From 12a92634fb467e6da23ac3026cd4fcbba4313f44 Mon Sep 17 00:00:00 2001 From: online-stuff Date: Wed, 21 Nov 2018 21:04:18 -0700 Subject: [PATCH 07/13] Rename touchfolder to Empty.txt --- .keys/{touchfolder => Empty.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .keys/{touchfolder => Empty.txt} (100%) diff --git a/.keys/touchfolder b/.keys/Empty.txt similarity index 100% rename from .keys/touchfolder rename to .keys/Empty.txt From 65dccd17682f7ff27cef08337792513d1c4d366c Mon Sep 17 00:00:00 2001 From: online-stuff Date: Wed, 21 Nov 2018 21:30:18 -0700 Subject: [PATCH 08/13] Create ReadMeInstall --- ReadMeInstall | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 ReadMeInstall diff --git a/ReadMeInstall b/ReadMeInstall new file mode 100644 index 0000000..ff8b2c1 --- /dev/null +++ b/ReadMeInstall @@ -0,0 +1,95 @@ +These are the commands I used (and a few of my notes) for a minimal Debian Stretch install.. +Software Selection - "SSH server" and 'standard system utilities" only + + + +sudo apt-get update +sudo apt-get install vim vim-doc vim-scripts wget curl git +sudo apt-get dist-upgrade +sudo reboot + +---The next few lines I setup my server authentication and other misc profile settings you can skip until sudo apt-get + +ssh-keygen + +echo "ssh-rsa AA...1Q== " >> .ssh/authorized_keys + +echo ":set mouse=" >> .vimrc +echo "set nocompatible" >> .vimrc + +vi .bashrc + +sudo visudo ---- tom ALL=(ALL) NOPASSWD:ALL + +sudo vi /etc/ssh/sshd_config - Enable 'PermitRootLogin prohibit-password' and 'PasswordAuthentication no' + +sudo apt-get update +sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common +curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - +sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" +sudo apt update +apt-cache policy docker-ce +sudo apt install docker-ce +sudo systemctl status docker +sudo usermod -aG docker ${USER} +exit + +id -nG +docker version +docker info +docker run hello-world + +sudo curl -L --fail https://github.com/docker/compose/releases/download/1.23.1/run.sh -o /usr/local/bin/docker-compose +sudo chmod +x /usr/local/bin/docker-compose + +wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg +sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/ +wget -q https://packages.microsoft.com/config/debian/9/prod.list +sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list +sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg +sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list + +curl -s -o bitwarden.sh https://raw.githubusercontent.com/bitwarden/core/master/scripts/bitwarden.sh && sudo chmod u+x bitwarden.sh +./bitwarden.sh install + +sudo apt-get update +sudo apt-get install dotnet-sdk-2.1 + +git clone https://github.com/online-stuff/BitBetter.git + +cd BitBetter/src/licenseGen/ +dotnet add package Newtonsoft.Json --version 11.0.0 + +cd ~/BitBetter/src/bitBetter +dotnet add package Newtonsoft.Json --version 11.0.0 + +cd ~/BitBetter/.keys +rm * + +openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.cert -days 36500 -outform DER -passout pass:test +openssl x509 -inform DER -in cert.cert -out cert.pem +openssl pkcs12 -export -out cert.pfx -inkey key.pem -in cert.pem -passin pass:test -passout pass:test + + +cd ~/BitBetter +./build.sh + +cd src/licenseGen/ +./build.sh + +cd ~ + +vi ~/bwdata/docker/docker-compose.yml - Change image: bitwarden/api:1.26.0 to image: bitbetter/api +vi ~/bwdata/env/global.override.env - Enter mail__smtp relay settings +vi ~/bwdata/scripts/run.sh - function restart() { dockerComposePull to #dockerComposePull + +./bitwarden start + +----Server should be up and running.. Create a user account + +cd ~/BitBetter/src/licenseGen/ +./build.sh +./run.sh ~/BitBetter/.keys/cert.pfx user "Name" "EMail" "User-GUID" + Get User-GUID from the admin portal of the BitWarden server + +./run.sh ~/BitBetter/.keys/cert.pfx org "Name" "EMail" "Install-ID used to install the server from bitwarden.com/host" From 1507f336c116c72562074ab289aca98a6b7dee28 Mon Sep 17 00:00:00 2001 From: online-stuff Date: Wed, 21 Nov 2018 21:37:36 -0700 Subject: [PATCH 09/13] Update README.md --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 525d9f7..6ddd5d5 100644 --- a/README.md +++ b/README.md @@ -50,11 +50,15 @@ This tool build ontop of the bitbetter/api container image so make sure you've b After that you can run the tool using: ```bash -./src/LicenseGen/run.sh +cd ~/BitBetter/src/licenseGen +./run.sh ~/BitBetter/.keys/cert.pfx user "Name" "EMail" "User-GUID" +./run.sh ~/BitBetter/.keys/cert.pfx org "Name" "EMail" "Install-ID used to install the server" ``` # Questions (you might have?) +I'll work on updates in the next couple weeks, right now, I just wanted something to start with. + ## But why? Its open source? Yes, bitwarden is great. If I didn't care about it i wouldn't be doing this. @@ -65,7 +69,6 @@ To host it myself. And maintain it myself. Basically WTH was bitwarden doing tha ## You should have reached out to bitwarden Thanks, good idea. And I did. Currently they're not focused on solving this issue - yet. -To be clear i'm totally happy to give them my money. Offer a perpetual family license, and i'd pay for it. -Offer me a license thats tied to a version, I'll gladly rebuy another when a new version comes out AND i'm ready to upgrade. +To be clear i'm totally happy to give them my money. Offer a perpetual server license, and i'd pay for it. Let me license the server, period. Allow an orginzation to have Premium for all users.. 500 seats, let the 500 users in the orginzation have the Premium features too. -I provided all these suggestions to bitwarden and they told me to wait until next year. Until then there's this. +I'm still in the testing/evaluating phase. If I am hosting the server/data, let me license the server, period. How many licenses does one user need to have... From 27869735fbbfa05e8dd93e6afd4f508614e79205 Mon Sep 17 00:00:00 2001 From: online-stuff Date: Wed, 21 Nov 2018 21:39:13 -0700 Subject: [PATCH 10/13] Update README.md --- README.md | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/README.md b/README.md index 6ddd5d5..dd8166f 100644 --- a/README.md +++ b/README.md @@ -15,25 +15,9 @@ replace anywhere `bitwarden/api` is used with `bitbetter/api` and give it a go. ## Issuing your own licenses -The repo is setup to replace the licesning signing cert in bitwarden.core with my own personal self signed cert (`cert.cert`) +The repo is setup to replace the licesning signing cert in bitwarden.core with your own personal self signed cert (`cert.cert`) If you want to be able to sign your own licenses obviously you'll have to replace it with your own self signed cert. -you can generate one with openssl like so: -```bash -openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.cert -days 36500 -outform DER -``` - -### Convert your DER certificate to a PEM - -```bash -openssl x509 -inform DER -in cert.cert -out cert.pem -``` - -### Convert your public and private key into a PKCS12/PFX - -```bash -openssl pkcs12 -export -out cert.pfx -inkey key.pem -in cert.pem -``` ### Signing licesnses From 6d3d1ee3f1fcc737a40995d3988629d0a2a6603b Mon Sep 17 00:00:00 2001 From: online-stuff Date: Wed, 21 Nov 2018 22:03:21 -0700 Subject: [PATCH 11/13] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dd8166f..d5ea48c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ # BitBetter -[![CircleCI](https://img.shields.io/circleci/project/github/jakeswenson/BitBetter.svg)](https://circleci.com/gh/jakeswenson/BitBetter/tree/master) This project is a tool to modify bitwardens core dll to allow me to self license. Beware this does janky IL magic to rewrite the bitwarden core dll and install my self signed certificate. +Yes, there still are quite a few things that need to be fixed. Updates and Organization Buiness Name is hardcoded to Bitbetter, are the first to things to fix.. Better handling of the User-GUID comes to mind too. + ## Building To build your own `bitwarden/api` image run @@ -15,7 +16,7 @@ replace anywhere `bitwarden/api` is used with `bitbetter/api` and give it a go. ## Issuing your own licenses -The repo is setup to replace the licesning signing cert in bitwarden.core with your own personal self signed cert (`cert.cert`) +The repo is setup to replace the licesning signing cert in bitwarden.core with your own personal self signed cert (`cert.pfx`) If you want to be able to sign your own licenses obviously you'll have to replace it with your own self signed cert. From b87c8c5e849d4e5c84da4c95220ace7798024a3c Mon Sep 17 00:00:00 2001 From: online-stuff Date: Wed, 21 Nov 2018 23:36:46 -0700 Subject: [PATCH 12/13] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d5ea48c..346749e 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ Beware this does janky IL magic to rewrite the bitwarden core dll and install my Yes, there still are quite a few things that need to be fixed. Updates and Organization Buiness Name is hardcoded to Bitbetter, are the first to things to fix.. Better handling of the User-GUID comes to mind too. +Credit to https://github.com/h44z/BitBetter and https://github.com/jakeswenson/BitBetter + ## Building To build your own `bitwarden/api` image run From 9f1422ac680a99fc4af67f5abe84df56b392c8fb Mon Sep 17 00:00:00 2001 From: online-stuff Date: Fri, 30 Nov 2018 14:39:08 -0700 Subject: [PATCH 13/13] Removed /jobs commands, not needed anymore. --- src/bitBetter/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/bitBetter/Dockerfile b/src/bitBetter/Dockerfile index 040d604..b59756d 100644 --- a/src/bitBetter/Dockerfile +++ b/src/bitBetter/Dockerfile @@ -7,8 +7,6 @@ RUN dotnet /bitBetter/bitBetter.dll && \ echo "modified dll" && \ mv /app/Core.dll /app/Core.orig.dll && \ mv /app/modified.dll /app/Core.dll && \ - mkdir /jobs && \ - cp -f /app/Core.dll /jobs/Core.dll && \ echo "replaced dll" && \ rm -rf /bitBetter && rm -rf /newLicensing.cer && \ echo "cleaned up"