Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Luciano Barletta
/
computer-report-system
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 520622ca
authored
2019-09-24 11:31:37 -0300
by
Luciano Barletta
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added message checking
1 parent
e372f88b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
17 deletions
check.sh
send.sh
check.sh
View file @
520622c
LINE
=
1
while
IFS
=
read
-r ID
do
DATA
=
$(
curl -d
"id=
$ID
"
-H
"application/x-www-form-urlencoded"
192.168.15.75:5000/cons
)
echo
$DATA
done
< msg_id.txt
\ No newline at end of file
if
[
$(
echo
$ID
| cut -c1-1 | grep
[
0-9]
)
]
then
STATUS
=
$(
curl -d
"id=
$ID
"
192.168.15.75:5000/cons
)
if
[[
$STATUS
!
=
"queued"
]]
then
echo
$LINE
>> delete
fi
else
echo
$LINE
>> delete
fi
LINE
=
$((
$LINE
+
1
))
done
< msg_ids.txt
if
[
-e delete
]
then
tac delete > aux
cat aux > delete
while
IFS
=
read
-r LINE
do
sed
${
LINE
}
d msg_ids.txt > aux
cat aux > msg_ids.txt
done
< delete
rm delete
rm aux
fi
send.sh
View file @
520622c
...
...
@@ -3,12 +3,11 @@ MSG=$2
PHONE
=
$3
TYPE
=
$4
# receive public key if
one doesn't exis
t
# receive public key if
I don't have i
t
if
[
! -e server_rsa_key.pub
]
then
echo
"getting new public key from server"
PUB_KEY
=
$(
curl 192.168.15.75:5000/init
)
printf
"%s"
"
$PUB_KEY
"
> server_rsa_key.pub
echo
"getting public key from server"
curl 192.168.15.75:5000/key > server_rsa_key.pub
fi
# generate random key
...
...
@@ -18,26 +17,23 @@ openssl rand -base64 32 > rand.key
# encode data with random key
echo
"encoding
$MSG
with random key"
echo
"
$MSG
"
| openssl enc -aes-256-cbc -salt -out data.enc -pass file:./rand.key
#printf "%s" "$MSG" > data
# encrypt random key with server's pubkey
openssl rsautl -encrypt -inkey server_rsa_key.pub -pubin -in rand.key -out rand.key.enc
rm rand.key
# send data as file (with optional encripted symectric key)
curl -F
"data=@data.enc"
-F
"key=@rand.key.enc"
192.168.15.75:5000/data
#curl -F "data=@data" 192.168.15.75:5000/data
MSG_ID
=
$(
curl -F
"data=@data.enc"
-F
"key=@rand.key.enc"
192.168.15.75:5000/data
)
# send the rest of the parameter to send the data
echo
"calling message sending method of server"
DATA
=
$(
curl -d
"serv=
$SERV
"
-d
"dest=
$PHONE
"
-d
"type=
$TYPE
"
192.168.15.75:5000/msg
)
echo
$DATA
>> msg_ids.txt
ID
=
$(
curl -d
"id=
$MSG_ID
"
-d
"serv=
$SERV
"
-d
"dest=
$PHONE
"
-d
"type=
$TYPE
"
192.168.15.75:5000/msg
)
echo
$ID
>> msg_ids.txt
# cleanup
rm ./rand.key.enc
rm ./data.enc
rm rand.key.enc
rm data.enc
rm rand.key
# DEBUGGING
rm /dev/shm/info_colmena
rm ./server_rsa_key.pub
\ No newline at end of file
rm server_rsa_key.pub
\ No newline at end of file
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment