The online hack that led to the posting of hundreds of explicit photos of some of Hollywood's most famous female stars could have been down to an attack on their passwords.

Stars including actress Jennifer Lawrence and model Kate Upton saw intimate photos posted on forum site 4chan on Sunday, with some reports at first concluding that Apple's iCloud service had been compromised to access the images.

A piece of computer code that repeatedly guesses passwords has been found online. The script was posted to software site GitHub, but a message has since appeared saying that Apple has issued a "patch" or fix for the bug.

"The end of the fun, Apple has just patched," read an update on the post.

The technology giant is yet to make any comment on the incident. According to the post, the script uses the top 500 most common passwords approved by Apple in order to try and gain access to user accounts.

If successful, it would give the hacker full access to the iCloud account, and therefore photos.

Owen Williams from technology site The Next Web, who found the bug, said: "The Python script found on GitHub appears to have allowed a malicious user to repeatedly guess passwords on Apple's Find my iPhone service without alerting the user or locking out the attacker.

"Given enough patience and the apparent hole being open long enough, the attacker could use password dictionaries to guess common passwords rapidly.

"If the attacker was successful and gets a match by guessing passwords against Find my iPhone, they would be able to, in theory, use this to log into iCloud and sync the iCloud Photo Stream with another Mac or iPhone in a few minutes, again, without the attacked user's knowledge."

Experts have pointed to the weakness of many internet users' passwords, and basic security knowledge as being the cause for the leak.

ICloud is Apple's own cloud service, a wireless storage facility that can be used to access files remotely.