Skip to content
This repository has been archived by the owner on Nov 19, 2022. It is now read-only.

Commit

Permalink
Added "ls" command and "echoFile" command.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianb12321 committed Feb 21, 2018
1 parent ef711dc commit 774785b
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/Recon/ClientCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public void Disconnect(string Reason)
ReconManager.Client.Close();
}

public PromptBuilder GetCurrentPrompt()
{
return null;
}

public ClientBuilder RegisterClient()
{
ClientBuilder cb = new ClientBuilder(ClientType.Headless);
Expand Down
5 changes: 5 additions & 0 deletions src/RemotePlusClient/ClientCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ public void ChangePrompt(PromptBuilder newPrompt)
{
//TODO: Implement Prompt
}

public PromptBuilder GetCurrentPrompt()
{
return null;
}
#endregion

}
Expand Down
5 changes: 5 additions & 0 deletions src/RemotePlusClientCmd/ClientCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public void Disconnect(string Reason)
//ClientCmdManager.WaitFlag = false;
}

public PromptBuilder GetCurrentPrompt()
{
return ClientCmdManager.prompt;
}

public ClientBuilder RegisterClient()
{
ClientBuilder cb = new ClientBuilder(ClientType.CommandLine);
Expand Down
1 change: 0 additions & 1 deletion src/RemotePlusLibrary.Extension/ILibraryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace RemotePlusLibrary.Extension
public delegate void ServerHook(HookArguments args);
public interface ILibraryBuilder
{
Dictionary<string, List<ServerHook>> Hooks { get; }
string FriendlyName { get; }
string Name { get; }
string Version { get; }
Expand Down
6 changes: 4 additions & 2 deletions src/RemotePlusLibrary/IRemoteClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public interface IRemoteClient : IClient
{
[OperationContract(IsOneWay = true)]
void TellMessage(string Message, Logging.OutputLevel o);
[OperationContract(Name = "TellMessageToServerConsole", IsOneWay = true)]
[OperationContract(Name = "TellMessageToServerConsole")]
void TellMessageToServerConsole(UILogItem li);
[OperationContract(Name = "TellMessageToServerConsoleUsingString", IsOneWay = true)]
[OperationContract(Name = "TellMessageToServerConsoleUsingString")]
void TellMessageToServerConsole(string Message);
[OperationContract]
ClientBuilder RegisterClient();
Expand All @@ -35,5 +35,7 @@ public interface IRemoteClient : IClient
void SendSignal(SignalMessage signal);
[OperationContract(IsOneWay = true)]
void ChangePrompt(PromptBuilder newPrompt);
[OperationContract]
PromptBuilder GetCurrentPrompt();
}
}
29 changes: 29 additions & 0 deletions src/RemotePlusServer/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -531,5 +531,34 @@ public static CommandResponse deleteFile(CommandRequest args, CommandPipeline pi
return new CommandResponse((int)CommandStatus.Success);
}
}
[CommandHelp("Reads the specified file and prints the contents to the screen.")]
public static CommandResponse echoFile(CommandRequest args, CommandPipeline pipe)
{
if(File.Exists(args.Arguments[1].Value))
{
DefaultService.Remote.Client.ClientCallback.TellMessageToServerConsole(File.ReadAllText(args.Arguments[1].Value));
return new CommandResponse((int)CommandStatus.Success);
}
else
{
DefaultService.Remote.Client.ClientCallback.TellMessageToServerConsole(new UILogItem(OutputLevel.Error, "The file does not exist."));
return new CommandResponse((int)CommandStatus.Fail);
}
}
[CommandHelp("Lists all the files and directories in the current directory.")]
public static CommandResponse ls(CommandRequest args, CommandPipeline pipe)
{
StringBuilder builder = new StringBuilder();
foreach(string file in Directory.GetFiles(DefaultService.Remote.CurrentPath))
{
builder.Append(Path.GetFileName(file) + " ");
}
foreach (string directory in Directory.GetDirectories(DefaultService.Remote.CurrentPath))
{
builder.Append(Path.GetDirectoryName(directory) + " ");
}
DefaultService.Remote.Client.ClientCallback.TellMessageToServerConsole(builder.ToString());
return new CommandResponse((int)CommandStatus.Success);
}
}
}
2 changes: 2 additions & 0 deletions src/RemotePlusServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ private static void InitializeCommands()
DefaultService.Commands.Add("load-extensionLibrary", loadExtensionLibrary);
DefaultService.Commands.Add("cp", cp);
DefaultService.Commands.Add("deleteFile", deleteFile);
DefaultService.Commands.Add("echoFile", echoFile);
DefaultService.Commands.Add("ls", ls);
}

static bool CheckPrerequisites()
Expand Down
4 changes: 3 additions & 1 deletion src/RemotePlusServer/RemotePlusServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@
<DependentUpon>ServerControls.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
Expand Down

0 comments on commit 774785b

Please sign in to comment.