Last Official commit !

This commit is contained in:
= 2019-11-17 20:34:31 +01:00
parent d4a9f911b5
commit 7555614193
45 changed files with 151 additions and 235 deletions

View File

@ -0,0 +1 @@
monster 15e6534f-25ed-4ca4-abe5-487566bcd7b4 Aj_4lrs-82x0cq8i-J88XdETavUh3kPJO5UfleYZomk=

View File

@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDraRhBIudHq/dp
tkHBR0Hbns2+onuvjgvCjEcPVISW9yg2w2u3VXPYA/UfW5bwDhipvDs/vThKzmkU
Pr+Q4rIQnPvP2rtbweMGnxYuSineYk6iNRqFnVWerh6t+6OU/3/t2nYX6y/I2y6c
Yjb32vM7NT2ixsyRe7BFNqTPnBlaA+W/A/df5Y/g+iys06wnnghHzVdQ8REgKwv2
QHSKr5fgyh1BiarjWgWD1Gt7iSaY2jM6jUVyf21KwvWj7UmWuyHx/wgSVLx/lvtz
M3+tjGPjasra9O9V44z7Q6gaLaW9cBXInGGtRVIzmdgC/1XDaOifu7OZHkqFL+Gv
rqegkn9ZAgMBAAECggEBAJ6Tve3qyCdElTaVunerO5bow6m+JFle81cLTbbq9SII
vgMd4wqtuopyKAYGmYd9x2lXTgYiva/OmYQ0vLCptM9yIEKlEn69/eNw+O0XslqG
mHe2E/abxJhOrIYAs/HjptafydtU52yDEUPw+Rw/Voe01p83EYiS7GvDYoQjoAQ8
vwDIViw1Ey6aAU9+xpr/gA/ef1OSKknoa9UpWZCzsaxnncOg5AeAHiQRn6aY302q
UpHo2TjncfwvNLz11qu8ePiwOHDPm1PFgWd2iZ7g8AwNpv7E1ujgFvTAMUXqBQh8
BYkhGHwXmBClpHQmWUHolzDk2cV8HQ21+j/yNeDyK60CgYEA/I2lkqNBa0Zppgav
L57zWJyn4a7fF5uQuhvOrVFL3X/hZdM6vv9l2TN6g/7JP4PMu9RuwOWTuGeTVQcO
RtIZcNMbZUb7PrjNJK7E/Y/n+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sL9kB0iq+X
4ModQYmq41oFg9Rre4kmmNozOo1Fcn9tSsL1o+1Jlrsh8f8IElS8f5b7czN/rYxj
42rK2vTvVeOM+0OoGi2lvXAVyJxhrUVSM5nYAv9Vw2jon7uzmR5KhS/hr66noJJ/
WQIDAQAB
-----END PUBLIC KEY-----

View File

@ -0,0 +1,9 @@
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn//c9+fFvE8eML+a3Kmb
Oq3+fEHiMH9YTeSyl5ydz4wYqd0EFYJTojO6YoAOfeERd9AEcEdVv/HEgA4OPdt/
2CURlybLRwO2XYbIVyx4Lnc9I78utc8W3IxVnFc0eYPyguWgrM/lTPIUnu6vjw8X
KTKzXPr3NuvIITeWAnEjCGePnqC8MfupcgQ0LrZfDDUfcftxutbQNbP8WW08jDDG
srQNoa5+JzcSKW7Yz2RtipjpbEwjk1y3wUtjVXg/DtTAp7btEJ3RmyfQos1Pnu6q
cTUTbXLdmFmtzHNg2cSRlICcBhNU2hX5O2krbJsf5CKrC6O92a2JdaCMvNvaD2FL
TQIDAQAB
-----END PUBLIC KEY-----

View File

@ -0,0 +1 @@
15e6534f-25ed-4ca4-abe5-487566bcd7b4 Aj_4lrs-82x0cq8i-J88XdETavUh3kPJO5UfleYZomk= 0

View File

@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCf/9z358W8Tx4w
v5rcqZs6rf58QeIwf1hN5LKXnJ3PjBip3QQVglOiM7pigA594RF30ARwR1W/8cSA
Dg4923/YJRGXJstHA7ZdhshXLHgudz0jvy61zxbcjFWcVzR5g/KC5aCsz+VM8hSe
7q+PDxcpMrNc+vc268ghN5YCcSMIZ4+eoLwx+6lyBDQutl8MNR9x+3G61tA1s/xZ
bTyMMMaytA2hrn4nNxIpbtjPZG2KmOlsTCOTXLfBS2NVeD8O1MCntu0QndGbJ9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d8lH9yZKORT2VMQvGmYD
FZYf+kI03tTEaB3jjy7W8w84XHoWmagvb8SRI98lgwKBgBTuZHiiAs1RSASB4FIW
I8F+d38nNvBonzjf6fbiizL7wLomrZt/7uLQyIDEPqPoeVefYdgiMDly9IbS731y
a3kujhOhiysCu8oparaUze0C/MOqeLhS0OfyUd/wc9hX0FMBB22f++3Lvr4OZp7A
YUSHkUwm9UuPpI3IFgcsxeDU
-----END PRIVATE KEY-----

View File

@ -0,0 +1,9 @@
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn//c9+fFvE8eML+a3Kmb
Oq3+fEHiMH9YTeSyl5ydz4wYqd0EFYJTojO6YoAOfeERd9AEcEdVv/HEgA4OPdt/
2CURlybLRwO2XYbIVyx4Lnc9I78utc8W3IxVnFc0eYPyguWgrM/lTPIUnu6vjw8X
KTKzXPr3NuvIITeWAnEjCGePnqC8MfupcgQ0LrZfDDUfcftxutbQNbP8WW08jDDG
srQNoa5+JzcSKW7Yz2RtipjpbEwjk1y3wUtjVXg/DtTAp7btEJ3RmyfQos1Pnu6q
cTUTbXLdmFmtzHNg2cSRlICcBhNU2hX5O2krbJsf5CKrC6O92a2JdaCMvNvaD2FL
TQIDAQAB
-----END PUBLIC KEY-----

View File

@ -0,0 +1,9 @@
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA62kYQSLnR6v3abZBwUdB
257NvqJ7r44LwoxHD1SElvcoNsNrt1Vz2AP1H1uW8A4Yqbw7P704Ss5pFD6/kOKy
EJz7z9q7W8HjBp8WLkop3mJOojUahZ1Vnq4erfujlP9/7dp2F+svyNsunGI299rz
OzU9osbMkXuwRTakz5wZWgPlvwP3X+WP4PosrNOsJ54IR81XUPERICsL9kB0iq+X
4ModQYmq41oFg9Rre4kmmNozOo1Fcn9tSsL1o+1Jlrsh8f8IElS8f5b7czN/rYxj
42rK2vTvVeOM+0OoGi2lvXAVyJxhrUVSM5nYAv9Vw2jon7uzmR5KhS/hr66noJJ/
WQIDAQAB
-----END PUBLIC KEY-----

Binary file not shown.

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6" project-jdk-type="Python SDK" />
</project>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/pj_crypto_1_v2.iml" filepath="$PROJECT_DIR$/.idea/pj_crypto_1_v2.iml" />
</modules>
</component>
</project>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -1,151 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="8b6808a0-dab7-485f-abd0-e90e162bb69e" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.clients_keys" beforeDir="false" afterPath="$PROJECT_DIR$/.clients_keys" afterDir="false" />
<change beforePath="$PROJECT_DIR$/server_test_3.py" beforeDir="false" afterPath="$PROJECT_DIR$/server_test_3.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/utils/rsa_tenamortech_utils.py" beforeDir="false" afterPath="$PROJECT_DIR$/utils/rsa_tenamortech_utils.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/utils/symmetric_keys_manager_1.py" beforeDir="false" afterPath="$PROJECT_DIR$/utils/symmetric_keys_manager_1.py" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/server_test_3.py">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret line="5" column="41" selection-start-line="5" selection-start-column="41" selection-end-line="5" selection-end-column="41" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/utils/rsa_tenamortech_utils.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="466">
<caret line="108" column="15" lean-forward="true" selection-start-line="108" selection-start-column="15" selection-end-line="108" selection-end-column="15" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/utils/rsa_tenamortech_utils.py" />
<option value="$PROJECT_DIR$/server_test_3.py" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="100" />
<option name="y" value="52" />
<option name="width" value="1400" />
<option name="height" value="828" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="pj_crypto_1_v2" type="b2602c69:ProjectViewProjectNode" />
<item name="pj_crypto_1_v2" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="pj_crypto_1_v2" type="b2602c69:ProjectViewProjectNode" />
<item name="pj_crypto_1_v2" type="462c0819:PsiDirectoryNode" />
<item name="utils" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
</panes>
</component>
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="8b6808a0-dab7-485f-abd0-e90e162bb69e" name="Default Changelist" comment="" />
<created>1573564637760</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1573564637760</updated>
</task>
<servers />
</component>
<component name="ToolWindowManager">
<frame x="0" y="32" width="1600" height="868" extended-state="6" />
<layout>
<window_info id="Favorites" side_tool="true" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.24984147" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Version Control" />
<window_info anchor="bottom" id="Python Console" />
<window_info active="true" anchor="bottom" id="Terminal" visible="true" weight="0.3293011" />
<window_info anchor="bottom" id="Event Log" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
</layout>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/utils/rsa_tenamortech_utils.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="466">
<caret line="108" column="15" lean-forward="true" selection-start-line="108" selection-start-column="15" selection-end-line="108" selection-end-column="15" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/server_test_3.py">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret line="5" column="41" selection-start-line="5" selection-start-column="41" selection-end-line="5" selection-end-column="41" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>

Binary file not shown.

0
README.md Normal file → Executable file
View File

25
client_test_3.py Normal file → Executable file
View File

@ -1,3 +1,23 @@
#===========================================================================================
# _____ _____ _ _ _ __ __ ___ ____ _____ _____ ____ _ _
# |_ _| ____| \ | | / \ | \/ |/ _ \| _ \_ _| ____/ ___| | | |
# | | | _| | \| | / _ \ | |\/| | | | | |_) || | | _|| | | |_| |
# | | | |___| |\ |/ ___ \| | | | |_| | _ < | | | |__| |___| _ |
# |_| |_____|_| \_/_/ \_\_| |_|\___/|_| \_\|_| |_____\____|_| |_|
#
# Minimalist Auth Server V3 (Python 3.6)
# (This file contains the client code)
#
# Sources:
# https://nitratine.net/blog/post/asymmetric-encryption-and-decryption-in-python/
# https://stackoverflow.com/questions/8933237/how-to-find-if-directory-exists-in-python
# https://stackoverflow.com/questions/273192/how-can-i-safely-create-a-nested-directory
#
#
# ROMANET Valentin
#===========================================================================================
# Python TCP Client A
import socket
@ -16,7 +36,6 @@ from utils.symmetric_keys_manager_1 import *
host = socket.gethostname()
port = 2004
BUFFER_SIZE = 2000
#MESSAGE = input("tcpClientA: Enter message/ Enter exit:").encode('utf-8')
MESSAGE = ""
tcpClientA = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcpClientA.connect((host, port))
@ -25,6 +44,7 @@ got_pub_key_server = False
(private_key,public_key) = check_for_existing_keys()
public_key_pem = public_key_serializer(public_key)
def de_serialize_pub_key(public_key_pem):
return serialization.load_pem_public_key(public_key_pem,backend=default_backend())
@ -39,6 +59,8 @@ while MESSAGE != 'exit':
got_pub_key_server = True
print("[DEBUG] SessionID Found ! [ OK ]")
else:
print("[DEBUG] SessionID Found ! [ FAIL ]")
print("[DEBUG] Waiting for new SessionID [ ... ]")
#if find sessionID load it and negociate with server
#else send public key ...
print("[DEBUG] Receiving Server Public Key [ ... ]")
@ -60,6 +82,7 @@ while MESSAGE != 'exit':
print("[DEBUG] Waiting for new Symmetric Key and New SessionID [ OK ] ")
print("[DEBUG] Symmetric Key: [" + str(new_symmetric_key) + "]")
print("[DEBUG] SessionID : [" + new_session_id + "]")
print("[DEBUG] Waiting for new SessionID [ OK ]")
print("[DEBUG] Saving basic HandShake infos [ ... ] ")
save_sym_key_by_host(host, new_session_id, new_symmetric_key, public_key_server)

0
.clients_keys → draft/.clients_keys Normal file → Executable file
View File

0
.hosts_keys → draft/.hosts_keys Normal file → Executable file
View File

0
client_test_1.py → draft/client_test_1.py Normal file → Executable file
View File

0
client_test_2.py → draft/client_test_2.py Normal file → Executable file
View File

0
decrypted_file.txt → draft/decrypted_file.txt Normal file → Executable file
View File

0
encrypted_file.data → draft/encrypted_file.data Normal file → Executable file
View File

View File

0
private_key.key → draft/private_key.key Normal file → Executable file
View File

0
public_key.pub → draft/public_key.pub Normal file → Executable file
View File

0
server_test_1.py → draft/server_test_1.py Normal file → Executable file
View File

0
server_test_2.py → draft/server_test_2.py Normal file → Executable file
View File

0
keys_manager_1.py Normal file → Executable file
View File

22
server_test_3.py Normal file → Executable file
View File

@ -1,3 +1,22 @@
#===========================================================================================
# _____ _____ _ _ _ __ __ ___ ____ _____ _____ ____ _ _
# |_ _| ____| \ | | / \ | \/ |/ _ \| _ \_ _| ____/ ___| | | |
# | | | _| | \| | / _ \ | |\/| | | | | |_) || | | _|| | | |_| |
# | | | |___| |\ |/ ___ \| | | | |_| | _ < | | | |__| |___| _ |
# |_| |_____|_| \_/_/ \_\_| |_|\___/|_| \_\|_| |_____\____|_| |_|
#
# Minimalist Auth Server V3 (Python 3.6)
# (This file contains the server code)
#
# Sources:
# https://nitratine.net/blog/post/asymmetric-encryption-and-decryption-in-python/
# https://stackoverflow.com/questions/8933237/how-to-find-if-directory-exists-in-python
# https://stackoverflow.com/questions/273192/how-can-i-safely-create-a-nested-directory
#
#
# ROMANET Valentin
#===========================================================================================
import socket
from threading import Thread
from socketserver import ThreadingMixIn
@ -6,7 +25,7 @@ from utils.server_keys_manager import *
from utils.symmetric_keys_manager_1 import *
from utils.rsa_tenamortech_utils import *
# --- Init keys ---
()
def de_serialize_pub_key(public_key_pem):
return serialization.load_pem_public_key(public_key_pem,backend=default_backend())
@ -72,7 +91,6 @@ class ClientThread(Thread):
print("[DEBUG] I'm all yours... [ :) ]")
conn.send(encrypt_msg("login:".encode('utf-8'), public_key_client))
#print("Server received data:", data)
MESSAGE = input("Multithreaded Python server : Enter Response from Server/Enter exit:").encode('utf-8')
if MESSAGE == 'exit':
break

0
utils/__init__.py Normal file → Executable file
View File

0
utils/__pycache__/__init__.cpython-36.pyc Normal file → Executable file
View File

0
utils/__pycache__/client_keys_manager.cpython-36.pyc Normal file → Executable file
View File

0
utils/__pycache__/keys_manager_1.cpython-36.pyc Normal file → Executable file
View File

0
utils/__pycache__/server_keys_manager.cpython-36.pyc Normal file → Executable file
View File

0
utils/client_keys_manager.py Normal file → Executable file
View File

View File

@ -1 +0,0 @@
c8Vo7OdLcNQJL2aDeLVepcGwOkXxnibd_BiOL6r42TM=

0
utils/keys_manager_1.py Normal file → Executable file
View File

2
utils/rsa_tenamortech_utils.py Normal file → Executable file
View File

@ -74,7 +74,7 @@ def save_key(key, key_type, host):
path = root_file_path + 'client'
keys_dir_path = Path.home() / path
# Path exists ? If not we will create it
keys_dir_path.mkdir(exist_ok=True)
keys_dir_path.mkdir(parents=True, exist_ok=True)
if(key_type == 0):
key_pem = private_key_serializer(key)
key_path = keys_dir_path / 'id_rsa'

View File

@ -1,35 +0,0 @@
#===============================================================
# --- (Un)Pack msg length and msg itself ---
#===============================================================
from struct import *
import asyncio, socket
def send_msg(sock, msg):
# Prefix each message with a 4-byte length (network byte order)
msg = struct.pack('>I', len(msg)) + msg
sock.sendall(msg)
def send_msg_async(writer, msg):
# Prefix each message with a 4-byte length (network byte order)
msg = struct.pack('>I', len(msg)) + msg
writer.write(msg)
#sock.sendall(msg)
def recv_msg(reader):
# Read message length and unpack it into an integer
raw_msglen = reader.read(255)
if not raw_msglen:
return None
msglen = unpack('>I', raw_msglen)[0]
# Read the message data
return recvall(reader)
def recvall(reader, n):
# Helper function to recv n bytes or return None if EOF is hit
data = bytearray()
while len(data) < n:
packet = reader.read(n - len(data))
if not packet:
return None
data.extend(packet)
return data

0
utils/server_keys_manager.py Normal file → Executable file
View File

3
utils/symmetric_keys_manager_1.py Normal file → Executable file
View File

@ -6,7 +6,7 @@ import uuid
# To get user home directory
from pathlib import Path
import os
# Home made RSA Keys lib
from utils.rsa_tenamortech_utils import *
@ -87,6 +87,7 @@ def reload_session_by_host(host):
host_found = False
# --- Open session file
if os.path.isfile(str(root_file_path) + "/.known_hosts"):
with open(str(root_file_path) + "/.known_hosts") as f:
line = f.readline().rstrip()
while(line and host_found == False):