Skip to content

Commit f9a9a24

Browse files
committed
add IP and MAC obfuscation
1 parent 6062084 commit f9a9a24

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

test/unit/fetch_command_output.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,66 @@ do
155155
echo -e "$(napalm --user "$DEVUSERNAME" --password "$DEVPASSWORD" --vendor "$VENDOR" "$DEVICE" call --method-kwargs "command='$CMD'" "$METHOD" | sed 's/^"//;s/"$//;s/\\"/"/g')" > "$CMDFILE"
156156
done
157157

158+
echo "#### Preparing obfuscate script"
159+
echo "## IP addresses"
160+
IPs=$(cat "$CODIR/$TYPE/"*.txt \
161+
| sed -rn 's/.*[^0-9\.](([0-9]{1,3}\.){3}[0-9]{1,3})[^0-9\.].*/\1/gp' \
162+
| sort \
163+
| uniq
164+
)
165+
echo $IPs
166+
167+
for a in $IPs
168+
do
169+
oa=${a}
170+
oa=${oa//2/3}
171+
oa=${oa//4/3}
172+
oa=${oa//5/3}
173+
oa=${oa//6/7}
174+
oa=${oa//8/7}
175+
oa=${oa//9/7}
176+
177+
oa=" -e s/$a/$oa/g "
178+
179+
oIPs="$oIPs$oa "
180+
done
181+
182+
echo "## MAC addresses"
183+
MACs=$(cat "$CODIR/$TYPE/"*.txt \
184+
| sed -rn -e 's/.*[^0-9\.:a-f-](([[:xdigit:]]{2}[:.-]?){5}[[:xdigit:]]{2})[^0-9\.:a-f-].*/\1/gp' \
185+
| sort \
186+
| uniq
187+
)
188+
echo $MACs
189+
190+
for m in $MACs
191+
do
192+
om=${m}
193+
om=${om//1/2}
194+
om=${om//3/2}
195+
om=${om//6/2}
196+
om=${om//8/2}
197+
om=${om//b/2}
198+
om=${om//e/2}
199+
om=${om//4/a}
200+
om=${om//5/a}
201+
om=${om//7/a}
202+
om=${om//9/a}
203+
om=${om//c/a}
204+
om=${om//d/a}
205+
206+
om=" -e s/$m/$om/g "
207+
208+
oMACs="$oMACs$om "
209+
done
210+
211+
echo "## Obfuscate"
212+
echo oIPS=$oIPs
213+
echo oMACs=$oMACs
214+
sed -ri $oMACs $oIPs "$CODIR/$TYPE/"*.txt
215+
216+
echo "###################################################"
217+
echo "## Do not forget obfuscate other output: ##"
218+
echo "## passwords, secrets, keys, certificates ##"
219+
echo "## descriptions, names and other ... ##"
220+
echo "###################################################"

0 commit comments

Comments
 (0)