-
Notifications
You must be signed in to change notification settings - Fork 93
/
extract_client.sh
executable file
路132 lines (99 loc) 路 2.78 KB
/
extract_client.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
#
# PREPARE EVERYTHING
#
export LC_ALL=C
DIR="$(dirname "$(readlink -f "$0")")"
cd "$DIR/.support" || exit 1
echo Deleting existing files
# Scary!
rm -rf "$DIR"/ClientExtracted/*
rm -rf bins/*
rm -rf linux_bins/*
rm -f "$DIR"/BuildbotPaths/*
rm -rf "$DIR"/Protobufs/*
#
# EXTRACT EVERYTHING
#
echo Extracting archives
for z in archives/*.zip;
do
if [[ "$z" == *"bins"* ]];
then
unzip -q -n "$z" -d bins/
else
unzip -q -o "$z" -d "$DIR/ClientExtracted/"
fi
done
for z in linux_archives/*.zip;
do
if [[ "$z" == *"bins"* ]];
then
unzip -q -n "$z" -d linux_bins/
fi
done
#
# PROTOBUF DUMP
#
echo Dumping protobufs
# https://github.com/SteamRE/SteamKit/tree/master/Resources/ProtobufDumper
~/ProtobufDumper/ProtobufDumper bins/steamui.dylib "$DIR/Protobufs/" > /dev/null
~/ProtobufDumper/ProtobufDumper bins/steamclient.dylib "$DIR/Protobufs/" > /dev/null
# https://github.com/m4dEngi/steamworks_dumper
echo Dumping structs
#./steamworks_dumper/build/steamworks_dumper "linux_bins/ubuntu12_32/steamui.so" "$DIR/Structs/"
#./steamworks_dumper/build/steamworks_dumper "linux_bins/ubuntu12_32/steamclient.so" "$DIR/Structs/"
#
# BUILDBOT PATHS
#
echo Dumping buildbot paths
while IFS= read -r -d '' file
do
echo "Dumping $file"
name=$(basename "$file" .dylib);
strings "$file" | grep "/buildbot/" | sed "s/^[^\/]*\//\//" | sed "s/\:[0-9]*$//" | sort -u > "$DIR/BuildbotPaths/$name.txt"
./macho-strings/macho-strings -binary "$file" > "$DIR/Strings/$name.txt"
if [ $? -ne 0 ]; then
strings "$file" > "$DIR/Strings/$name.txt"
fi
./nm-with-macho -C -p "$file" | grep -Evi "GCC_except_table|google::protobuf|steam_rel_osx_builder" | awk '{$1=""; print $0}' | sort -u > "$DIR/Symbols/$name.txt"
done < <(find bins/ -name '*.dylib' -print0)
./macho-strings/macho-strings -binary "$DIR/ClientExtracted/steam_osx" > "$DIR/Strings/steam_osx.txt"
#
# Jump to extracted folder
#
ProcessClientFolder()
{
#
# PRETTIFY JAVASCRIPT
#
echo Prettifying javascript
while IFS= read -r -d '' file
do
if [[ "$file" == *.js ]]
then
php "$DIR/extract_json_from_webpack.php" "$(pwd)/$file"
if [ $? -eq 200 ]
then
echo "Extracted json from $file"
continue
fi
fi
echo "Prettifying $file"
npm run prettier "$(pwd)/$file"
done < <(find steamui/ clientui/ \( -name '*.js' -o -name '*.css' \) -print0)
#
# CHANGE CRAPPY ENCODINGS TO UTF-8
#
echo Fixing encodings
while IFS= read -r -d '' file
do
encoding=$(file -bi "$file" | sed -e 's/.*[ ]charset=//');
if [ "$encoding" != "utf-8" ] && [ "$encoding" != "binary" ];
then
iconv -f "$encoding" -t UTF-8 "$file" -o "$file.tmp" && mv "$file.tmp" "$file"
fi
done < <(find . \( -name '*.txt' -o -name '*.xml' -o -name '*.cfg' -o -name '*.res' \) -print0)
}
cd "$DIR/ClientExtracted/" || exit 1
ProcessClientFolder