Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
deviceCheat
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
luozhenzhen
deviceCheat
Commits
9917ef7a
Commit
9917ef7a
authored
Sep 20, 2019
by
luozhenzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改字符串存储为对象
parent
178f4418
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
75 additions
and
49 deletions
+75
-49
pom.xml
pom.xml
+5
-0
DeviceReturnDto.java
src/main/java/com/demo/entity/dto/DeviceReturnDto.java
+6
-4
DeviceConf.java
src/main/java/com/demo/entity/po/DeviceConf.java
+5
-4
DeviceInfo.java
src/main/java/com/demo/entity/po/DeviceInfo.java
+5
-4
SensorInfo.java
src/main/java/com/demo/entity/po/SensorInfo.java
+5
-4
DataImportController.java
src/main/java/com/demo/mongodb/DataImportController.java
+7
-3
DeviceService.java
src/main/java/com/demo/service/DeviceService.java
+18
-12
FileEncryptor.java
src/main/java/com/demo/util/FileEncryptor.java
+24
-18
No files found.
pom.xml
View file @
9917ef7a
...
...
@@ -25,6 +25,11 @@
<version>
1.2.54
</version>
</dependency>
<dependency>
<groupId>
commons-lang
</groupId>
<artifactId>
commons-lang
</artifactId>
<version>
2.6
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
...
...
src/main/java/com/demo/entity/dto/DeviceReturnDto.java
View file @
9917ef7a
package
com
.
demo
.
entity
.
dto
;
import
com.alibaba.fastjson.JSONObject
;
public
class
DeviceReturnDto
{
private
String
data
;
private
JSONObject
data
;
private
int
datelen
;
private
String
akey
;
//RSA加密的AES密钥
private
String
pkey
;
//RSA公钥
...
...
@@ -10,18 +12,18 @@ public class DeviceReturnDto {
public
DeviceReturnDto
()
{
}
public
DeviceReturnDto
(
String
data
,
int
datelen
,
String
akey
,
String
pkey
)
{
public
DeviceReturnDto
(
JSONObject
data
,
int
datelen
,
String
akey
,
String
pkey
)
{
this
.
data
=
data
;
this
.
datelen
=
datelen
;
this
.
akey
=
akey
;
this
.
pkey
=
pkey
;
}
public
String
getData
()
{
public
JSONObject
getData
()
{
return
data
;
}
public
void
setData
(
String
data
)
{
public
void
setData
(
JSONObject
data
)
{
this
.
data
=
data
;
}
...
...
src/main/java/com/demo/entity/po/DeviceConf.java
View file @
9917ef7a
package
com
.
demo
.
entity
.
po
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.data.mongodb.core.mapping.Document
;
...
...
@@ -10,24 +11,24 @@ import org.springframework.data.mongodb.core.mapping.Document;
@Document
(
collection
=
"DeviceConf"
)
public
class
DeviceConf
{
private
String
confInfo
;
private
JSONObject
confInfo
;
private
Boolean
status
;
private
String
os
;
public
DeviceConf
()
{
}
public
DeviceConf
(
String
confInfo
,
Boolean
status
,
String
os
)
{
public
DeviceConf
(
JSONObject
confInfo
,
Boolean
status
,
String
os
)
{
this
.
confInfo
=
confInfo
;
this
.
status
=
status
;
this
.
os
=
os
;
}
public
String
getConfInfo
()
{
public
JSONObject
getConfInfo
()
{
return
confInfo
;
}
public
void
setConfInfo
(
String
confInfo
)
{
public
void
setConfInfo
(
JSONObject
confInfo
)
{
this
.
confInfo
=
confInfo
;
}
...
...
src/main/java/com/demo/entity/po/DeviceInfo.java
View file @
9917ef7a
package
com
.
demo
.
entity
.
po
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
java.util.Date
;
...
...
@@ -8,14 +9,14 @@ import java.util.Date;
public
class
DeviceInfo
{
private
String
os
;
private
String
info
;
private
JSONObject
info
;
private
String
reyunId
;
private
Long
timestamp
;
public
DeviceInfo
()
{
}
public
DeviceInfo
(
String
os
,
String
info
,
String
reyunId
)
{
public
DeviceInfo
(
String
os
,
JSONObject
info
,
String
reyunId
)
{
this
.
os
=
os
;
this
.
info
=
info
;
this
.
reyunId
=
reyunId
;
...
...
@@ -30,11 +31,11 @@ public class DeviceInfo {
this
.
os
=
os
;
}
public
String
getInfo
()
{
public
JSONObject
getInfo
()
{
return
info
;
}
public
void
setInfo
(
String
info
)
{
public
void
setInfo
(
JSONObject
info
)
{
this
.
info
=
info
;
}
...
...
src/main/java/com/demo/entity/po/SensorInfo.java
View file @
9917ef7a
package
com
.
demo
.
entity
.
po
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.data.mongodb.core.mapping.Document
;
...
...
@@ -10,13 +11,13 @@ public class SensorInfo {
private
String
reyunId
;
private
Long
timestamp
;
private
String
sensorInfo
;
private
JSONObject
sensorInfo
;
private
String
os
;
public
SensorInfo
()
{
}
public
SensorInfo
(
String
reyunId
,
Long
timestamp
,
String
sensorInfo
,
String
os
)
{
public
SensorInfo
(
String
reyunId
,
Long
timestamp
,
JSONObject
sensorInfo
,
String
os
)
{
this
.
reyunId
=
reyunId
;
this
.
timestamp
=
timestamp
;
this
.
sensorInfo
=
sensorInfo
;
...
...
@@ -39,11 +40,11 @@ public class SensorInfo {
this
.
timestamp
=
timestamp
;
}
public
String
getSensorInfo
()
{
public
JSONObject
getSensorInfo
()
{
return
sensorInfo
;
}
public
void
setSensorInfo
(
String
sensorInfo
)
{
public
void
setSensorInfo
(
JSONObject
sensorInfo
)
{
this
.
sensorInfo
=
sensorInfo
;
}
...
...
src/main/java/com/demo/mongodb/DataImportController.java
View file @
9917ef7a
...
...
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
import
com.alibaba.fastjson.JSONObject
;
import
com.demo.entity.po.DeviceConf
;
import
com.demo.util.ResultObject
;
import
org.apache.commons.lang.StringEscapeUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -312,7 +313,9 @@ public class DataImportController {
str
=
str
.
replaceAll
(
"\n"
,
""
);
str
=
str
.
replaceAll
(
"\t"
,
""
);
DeviceConf
deviceConf
=
new
DeviceConf
(
str
,
true
,
"ios"
);
str
=
StringEscapeUtils
.
unescapeJavaScript
(
str
);
JSONObject
data
=
JSON
.
parseObject
(
str
);
DeviceConf
deviceConf
=
new
DeviceConf
(
data
,
true
,
"ios"
);
mongoTemplate
.
insert
(
deviceConf
);
return
new
ResultObject
(
HttpServletResponse
.
SC_OK
);
...
...
@@ -750,9 +753,10 @@ public class DataImportController {
"}"
;
str
=
str
.
replaceAll
(
"\n"
,
""
);
str
=
str
.
replaceAll
(
"\t"
,
""
);
DeviceConf
deviceConf
=
new
DeviceConf
(
str
,
true
,
"android"
);
str
=
StringEscapeUtils
.
unescapeJavaScript
(
str
);
JSONObject
data
=
JSON
.
parseObject
(
str
);
DeviceConf
deviceConf
=
new
DeviceConf
(
data
,
true
,
"android"
);
mongoTemplate
.
insert
(
deviceConf
);
return
new
ResultObject
(
HttpServletResponse
.
SC_OK
);
}
...
...
src/main/java/com/demo/service/DeviceService.java
View file @
9917ef7a
...
...
@@ -14,6 +14,7 @@ import com.reyun.Algorithm;
import
com.demo.util.DeformedBase64
;
import
com.demo.util.RSAUtil
;
import
com.demo.util.SecretUtil
;
import
org.apache.commons.lang.StringEscapeUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -116,11 +117,11 @@ public class DeviceService {
logger
.
info
(
"getDeviceConf 获取配置信息失败:{}"
,
JSONObject
.
toJSONString
(
deviceConfVo
));
return
null
;
}
String
data
=
deviceConf
.
getConfInfo
();
JSONObject
data
=
deviceConf
.
getConfInfo
();
try
{
logger
.
info
(
"secret.getAesKey():{} secret.getPrivateRsaKey():{}"
,
secret
.
getAesKey
(),
secret
.
getPrivateRsaKey
());
DeviceReturnDto
deviceReturnDto
=
new
DeviceReturnDto
(
data
,
data
.
length
(),
DeviceReturnDto
deviceReturnDto
=
new
DeviceReturnDto
(
data
,
data
.
toJSONString
().
length
(),
SpecialSecret
.
getSecretAesStr
(
secret
.
getAesKey
(),
secret
.
getPrivateRsaKey
()),
SpecialSecret
.
getSecretRSAStr
(
secret
.
getPublicRsaKey
()));
...
...
@@ -190,24 +191,27 @@ public class DeviceService {
}
}
String
reyunId
=
getReyunId
(
clientReyunId
,
deviceId
,
secret
.
getPublicRsaKey
());
// String reyunId = UUID.randomUUID()+"";
reyunIdMap
.
put
(
"reyunId"
,
reyunId
);
String
reyunIdReal
=
reyunId
.
replaceAll
(
"\\\\"
,
""
);
//去掉\反义字符,防止后面转化的时候导致不一致
reyunIdMap
.
put
(
"reyunId"
,
reyunId
Real
);
//区分系统保存数据
//去掉转义字符
data
=
StringUtils
.
isEmpty
(
data
)
?
data
:
data
.
replaceAll
(
"\\\\"
,
""
);
DeviceInfo
deviceInfo
=
new
DeviceInfo
(
osEnum
.
getVal
(),
data
,
reyunId
);
data
=
StringUtils
.
isEmpty
(
data
)
?
data
:
data
.
replaceAll
(
"\n"
,
""
);
String
dataReal
=
StringEscapeUtils
.
unescapeJavaScript
(
data
);
JSONObject
jsonData
=
JSONObject
.
parseObject
(
dataReal
);
DeviceInfo
deviceInfo
=
new
DeviceInfo
(
osEnum
.
getVal
(),
jsonData
,
reyunIdReal
);
deviceInfoDao
.
insert
(
deviceInfo
);
String
dataStr
=
JSONObject
.
toJSONString
(
reyunIdMap
);
JSONObject
result
=
(
JSONObject
)
JSON
.
toJSON
(
reyunIdMap
);
try
{
DeviceReturnDto
deviceReturnDto
=
new
DeviceReturnDto
(
dataStr
,
dataStr
.
length
(),
DeviceReturnDto
deviceReturnDto
=
new
DeviceReturnDto
(
result
,
result
.
toJSONString
()
.
length
(),
SpecialSecret
.
getSecretAesStr
(
secret
.
getAesKey
(),
secret
.
getPublicRsaKey
()),
SpecialSecret
.
getSecretRSAStr
(
secret
.
getPublicRsaKey
()));
String
result
=
SpecialSecret
.
aesData
(
JSONObject
.
toJSONString
(
deviceReturnDto
),
secret
.
getAesKey
());
return
result
;
String
result
Str
=
SpecialSecret
.
aesData
(
JSONObject
.
toJSONString
(
deviceReturnDto
),
secret
.
getAesKey
());
return
result
Str
;
}
catch
(
Exception
e
){
logger
.
info
(
"getDeviceId 获取dll动态库失败:{}"
,
JSONObject
.
toJSONString
(
deviceIdVo
));
}
...
...
@@ -320,8 +324,10 @@ public class DeviceService {
//保存数据
String
reyunId
=
dataObject
.
getString
(
"reyunId"
);
//去掉转义字符
data
=
StringUtils
.
isEmpty
(
data
)
?
data
:
data
.
replaceAll
(
"\\\\"
,
""
);
SensorInfo
sensorInfo
=
new
SensorInfo
(
reyunId
,
new
Date
().
getTime
(),
data
,
osEnum
.
getVal
());
data
=
StringUtils
.
isEmpty
(
data
)
?
data
:
data
.
replaceAll
(
"\n"
,
""
);
String
dataReal
=
StringEscapeUtils
.
unescapeJavaScript
(
data
);
JSONObject
dataJson
=
JSONObject
.
parseObject
(
dataReal
);
SensorInfo
sensorInfo
=
new
SensorInfo
(
reyunId
,
new
Date
().
getTime
(),
dataJson
,
osEnum
.
getVal
());
sensorInfoDao
.
insert
(
sensorInfo
);
return
true
;
}
...
...
src/main/java/com/demo/util/FileEncryptor.java
View file @
9917ef7a
...
...
@@ -87,7 +87,7 @@ public class FileEncryptor {
}
public
static
byte
[]
inputStreamToByte
(
InputStream
input
)
throws
IOException
{
byte
[]
b
=
new
byte
[
4096
];
byte
[]
b
=
new
byte
[
input
.
available
()
];
for
(
int
n
;
(
n
=
input
.
read
(
b
))
!=
-
1
;)
{
}
return
b
;
...
...
@@ -171,7 +171,7 @@ public class FileEncryptor {
public
static
void
downloadFileToPath
(
String
sourceFilePath
,
String
fileName
,
HttpServletResponse
resp
)
throws
Exception
{
String
realName
=
fileName
;
try
{
realName
=
URLEncoder
.
encode
(
realName
,
"utf-8"
);
realName
=
URLEncoder
.
encode
(
realName
,
"utf-8"
);
}
catch
(
Exception
e
){
...
...
@@ -183,23 +183,22 @@ public class FileEncryptor {
try
{
File
sourceFile
=
new
File
(
sourceFilePath
);
if
(
sourceFile
.
exists
()
&&
sourceFile
.
isFile
())
{
if
(
sourceFile
.
exists
()
&&
sourceFile
.
isFile
())
{
FileInputStream
in
=
new
FileInputStream
(
sourceFile
);
out
=
resp
.
getOutputStream
();
FileInputStream
in
=
new
FileInputStream
(
sourceFile
);
out
=
resp
.
getOutputStream
();
// byte[] cache = new byte[CACHE_SIZE];
// int nRead = 0;
// while ((nRead = in.read(cache)) != -1) {
// out.write(cache, 0, nRead);
// out.flush();
// }
int
nRead
=
0
;
while
((
nRead
=
in
.
read
())
!=
-
1
)
{
out
.
write
(
nRead
);
out
.
flush
();
}
}
byte
[]
data
=
inputStreamToByte
(
in
);
//base64
char
[]
aesData
=
DeformedBase64
.
encode
(
data
);
ByteArrayInputStream
cin
=
StringToInputStream
(
getBytes
(
aesData
));
int
nRead
=
0
;
while
((
nRead
=
cin
.
read
())
!=
-
1
)
{
out
.
write
(
nRead
);
out
.
flush
();
}
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -219,6 +218,13 @@ public class FileEncryptor {
//// InputStream in = new FileInputStream(sourceFilePath);
//// System.out.println(inputStreamToString(in));
//// downloadFileToPath(sourceFilePath, "C:\\Users\\reyun\\Desktop\\mongo.jar");
// }
// String data = "{ \"initialFirmware\" : \"8.0\", \"riskExist\" : \"0\", \"systemVersion\" : \"11.1\", \"isp\" : \"46001\", \"netWorkType\" : \"WIFI\", \"usedDiskValue\" : \"6363.00\", \"iPhoneName\" : \"iPhone\", \"purgableMemoryValue\" : \"7.95\", \"totalMemoryValue\" : \"989.00\", \"wifiDbm\" : \"-64\", \"wifiAddress\" : \"fe80::14fb:2b53:573a:9331\", \"platform\" : \"iOS\", \"allBusFrequency\" : 0, \"isDebugging\" : \"1\", \"freeMemoryValue\" : \"55.17\", \"totalDiskValue\" : \"15248.76\", \"systemWiredMemoryValue\" : \"190.02\", \"useLanuage\" : \"zh-Hans-CN\", \"localDeviceIp\" : \"192.168.168.124\", \"networkIp\" : \"119.57.108.226\", \"isUsingVPN\" : \"0\", \"cpuUsage\" : 0.2101379781961441, \"reyunId\" : \"QLQ08\\/KgnyoqYZEPNp4bv\\/ySCP5QN\\/NxM348iR6qQZNcNLBKYeBEg54+ClBGny7P2L4plE8\\/le5ZNi4fvR708Sp15R7UMi7e5SYLmluIT5\\/1vGKeNbNck\\/5HTijdi\\/5lvMYG5S7JkR7hQ5QMgM8\\/CPN2QSQenbCfi5NRmPNvgZ\\/4CppKmE8ZMeroNsudlsBPgbXvcp7Tkbuqe3grcbYJCi8vlEP8veKiNDLoJc==\", \"remainBattery\" : \"1647.10\", \"systemName\" : \"iOS\", \"batteryStatus\" : \"Charging\", \"ramMemorySize\" : 1037041664, \"isJailbreak\" : \"1\", \"screenWidth\" : \"375.00\", \"screenBrightness\" : \"0.56\", \"cpuName\" : \"Apple A8\", \"wifiStrength\" : 3, \"deviceName\" : \"iPhone 6\", \"idfv\" : \"BBEF0D9C-75A2-41D8-ACB3-0BB367965E37\", \"cellStrength\" : 4, \"ispName\" : \"中国联通\", \"canMakePhoneCall\" : \"1\", \"httpProxy\" : \"192.168.168.176\", \"networkCountryIso\" : \"cn\", \"screenHeight\" : \"667.00\", \"batteryVoltage\" : \"3.82\", \"httpPort\" : 8888, \"batteryCapacityValue\" : \"1810\", \"currentCountry\" : \"zh_CN\", \"activeMemoryValue\" : \"474.96\", \"iPhoneCellIP\" : \"null\", \"gatewayAddress\" : \"192.168.168.1\", \"idfa\" : \"8AAAC858-396E-4467-8B47-7EF1363B4EDD\", \"appVersion\" : \"1.0\", \"localizedModel\" : \"iPhone\", \"ssidName\" : \"Reyun-online5G\", \"latestSystemUptime\" : \"2019-09-20 18:25:29\", \"usedMemoryValue\" : \"860.39\", \"latestFirmware\" : \"12.3.1\", \"deviceModel\" : \"iPhone7,2\", \"perCPUUsage\" : \"0.18|0.03\", \"isAppActive\" : \"1\", \"batteryLevel\" : \"0.91\", \"isInjection\" : \"0\", \"isUsingProxy\" : \"1\", \"cpuFrequency\" : 0, \"cpuCounts\" : 2, \"inActiveMemoryValue\" : \"195.41\", \"freeDiskValue\" : \"8885.77\"}\n";
// System.out.println(data.replaceAll("\\\\",""));
// String str = data.replaceAll("\\\\","");
// System.out.println(str);
//
//
// }
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment