How to save the sudo password in AppleScript?
Instead of temporarily storing your password in an application/AppleScript it might be easier to enable password-less sudo access to ping:


Run sudo visudo to open the sudoers file
Add a line %admin ALL=(ALL) NOPASSWD: /sbin/ping to give all users in the admin group password-less access to sudo ping


Afterwards you can just use sudo ping from Terminal or Applescript.

$ sudo ping -s 65000 askdifferent.com
PING askdifferent.com (104.27.182.101): 65000 data bytes
65008 bytes from 104.27.182.101: icmp_seq=0 ttl=56 time=1250.724 ms
65008 bytes from 104.27.182.101: icmp_seq=1 ttl=56 time=4.107 ms
65008 bytes from 104.27.182.101: icmp_seq=2 ttl=56 time=3.943 ms


This works even without enabling the root account.

PS: Never edit /etc/sudoers directly, always use sudo visudo to do so. visudo applies basic sanity checks on the file when saving, you risk to lock yourself out of sudo if you get things wrong by editing the file directly.